CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Guest

    Problem with List Control (Report Style)

    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


  2. #2
    Join Date
    Jul 1999
    Location
    Moscow, Russia
    Posts
    667

    Re: Problem with List Control (Report Style)

    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



  3. #3
    Guest

    Re: Problem with List Control (Report Style)

    Hi,
    Where/when should I call this function ? Can I call this function inside OnInitDialog ?
    Thanks
    Prashanth



  4. #4
    Join Date
    Jul 1999
    Location
    Moscow, Russia
    Posts
    667

    Re: Problem with List Control (Report Style)

    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


  5. #5
    Guest

    Re: Problem with List Control (Report Style)

    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


  6. #6
    Guest

    Re: Problem with List Control (Report Style)

    Hi,
    I checked the MSDN ! It talks about "List View" ! Will it work for "List Control" on a dialog also ?
    Prashanth


  7. #7
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    418

    Re: Problem with List Control (Report Style)

    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

  8. #8
    Guest

    Re: Problem with List Control (Report Style)

    Hi Martin & Oleg,
    thats great ! Yeah it works perfectly ! As you said, i used SetExtendedStyle functions.

    Thanks a lot!

    Regards
    Prashanth


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured