Click to See Complete Forum and Search --> : Problem with List Control (Report Style)


August 27th, 1999, 01:46 AM
Hi,
I have a lis t control in my dialog with two columns. The style of the list control is report. The problem is when selection happens I can see only the item in the first column selected. What I wanted was the highlight should appear (span) across the entire row ! Looks like i have to set some property for the control.
The funniest thing is in one of my other dialog i am able to do it ! But i don't know why its not happening in my new dialog.
Can anybody help me with this ?
Thanks
Regards
Prashanth

Oleg Lobach
August 27th, 1999, 03:01 AM
Use code:



CYourListCtrl* pListCtrl = (CYourListCtrl *) pointerToDialogClass->GetDlgItem(ID_Of_YourListCtrl);
pListCtrl->ModifyStyle(0,LVS_EX_FULLROWSELECT,0);





For additional styles look at "Extended list view styles" in MSDN.

Good luck.

Oleg

August 27th, 1999, 03:30 AM
Hi,
Where/when should I call this function ? Can I call this function inside OnInitDialog ?
Thanks
Prashanth

Oleg Lobach
August 27th, 1999, 03:54 AM
Yes, you can call it inside OnInitDialog, unless you creating your CListCtrl on the fly somewere after OnInitDialog. In this case call ModifyStyle(...) after creating CListCtrl.

Good luck,
Oleg

August 27th, 1999, 05:54 AM
Hi,
its not working ! Here is my Code !
Actually I created a MFC dialog App(using the App wizard) andd added the following lines to the OnInitDialog().


// Populate Header of List Control
m_CtrlList.InsertColumn(0, _T("Number"), LVCFMT_CENTER, 50, 0);
m_CtrlList.InsertColumn(1, _T("Description"), LVCFMT_CENTER, 125, 1);
m_CtrlList.ModifyStyleEx(0, LVS_EX_FULLROWSELECT, 0); //Tried with ModifyStyle() also

CString strData;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;

for (int nIndex = 0; nIndex < 10; nIndex++)
{
strData.Format(_T("%d"), nIndex);

lvItem.iItem = nIndex;
lvItem.iSubItem = 0;
lvItem.pszText = (LPTSTR)(LPCTSTR)strData;
m_CtrlList.InsertItem(&lvItem);
// Add data to col two
strData = strData + strData;
lvItem.iSubItem = 1;
lvItem.pszText = (LPTSTR)(LPCTSTR)strData;
m_CtrlList.SetItem(&lvItem);

}




I have NT 4.0 with IE 5.0 ...

What could be the problem here ?

Thanks
Prashanth

August 27th, 1999, 06:06 AM
Hi,
I checked the MSDN ! It talks about "List View" ! Will it work for "List Control" on a dialog also ?
Prashanth

Martin Speiser
August 27th, 1999, 06:18 AM
Hi Prashant,

CListCtrl is the MFC wrapper for the common control ListView. It's confusing, because it can be held for CListView. Thanks MS!

To your problem: use the function SetExtendedStyle. LVS_EX_FULLROWSELECT can't be set with ModifyStyleEx. Looks like it isn't a windows extended style. Another time for thanks MS!


Martin

August 27th, 1999, 07:36 AM
Hi Martin & Oleg,
thats great ! Yeah it works perfectly ! As you said, i used SetExtendedStyle functions.

Thanks a lot!

Regards
Prashanth