Re: CCheckListBox
Hi Manjree,
Thanks for your updating.
I think that you real meaning was to have your CDatabaseView behave like
CCheckListBox, right?
CListView and CCheckListBox are incompatible classes, no inheried hiarachy
relationship between them. A CListView instance contains a CListCtrl
instance which provides checkbox style.
Since your CDatabaseView is derived from CListView, you can directly call
the member function GetListCtrl() to retrieve the CListCtrl object which is
not CListView type but CListCtrl type.
Please forgive me if I misunderstand your requirement, I do not think that
you need CCheckListBox any more since you have used the class CDatabaseView
which is derived from CListView.
Anyway, I think that it is better to use code snippets to demonstrate the
usage of your CDatabaseView with checkbox:
//CDatabaseView definition
class CDatabaseView:public CListView
{
public:
CDatabaseView(){}
~CDatabaseView(){}
......
}
class CMyTestView:public CView
{
public:
CDatabaseView m_dbView;
protected:
CListCtrl& m_listCtrl;
......
}
void CMyTestView::OnInitialUpdate()
{
......
m_listCtrl = m_dbView.GetListCtrl();
CRect rect;
m_listCtrl.GetClientRect(rect);
m_listCtrl.InsertColumn(0, _T("No."), LVCFMT_LEFT, 80);
m_listCtrl.InsertColumn(1, _T("Progress"), LVCFMT_LEFT, 150);
m_listCtrl.InsertColumn(2, _T("Description"), LVCFMT_LEFT, rect.Width() -
230);
//Initialize items (rows)
CString cs(_T(""));
for(int i = 0; i < 5; i++)
{
cs.Format(_T("%d"), i+1);
m_listCtrl.InsertItem(i, cs);
cs.Format(_T("It's the %d item"), i+1);
m_listCtrl.SetItemText(i, 2, cs);
}
//This line enables your CDatabaseView having checkbox
m_listCtrl.SetExtendedStyle( m_listCtrl.GetExtendedStyle() |
LVS_EX_CHECKBOXES);
m_listCtrl.Init();
}
Hope this helps. Please feel free to let me know if you have any other
questions or concerns.
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================