Re: CCheckListBox
Hi Charles
Thanks for your reply.
I am sorry, I did not mean initialise. I meant declaring CListView as type
of CCheckListBox.
I derived my view class CDataBaseView from CListView. So when I need list
control in ay of the member function of the class I use
CListCtrl& lst = GetListCtrl();
so lst is of CListView type. Now If I want it to behave like CCheckListBox
as m_listCtrl in the example, how can I declare it of that type?
cheers
Manjree
"Charles Wang[MSFT]" wrote:
Hi Manjree,
What is your real meaning of initialising your CListView using
CCheckListBox?
To let us better understand your question, could you please describe your
requirement more detailed?
If you would like to know how to initialize a CListView control, the 2nd
link from Tom's suggestion include the following code for the
initialization:
// Initialize columns
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);
}
m_listCtrl.SetExtendedStyle( m_listCtrl.GetExtendedStyle() |
LVS_EX_CHECKBOXES);
m_listCtrl.Init();
If you want to have one item checked during the initialization, you can
call:
m_listCtrl.SetCheck(nItemIndex, TRUE);
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.
======================================================