我想选中列表控件(listctrl)中的某一列,并改变选中列的颜色,请问改如何做?谢谢!

解决方案 »

  1.   

    看看这个消息
    WM_CTLCOLORLISTBOX
    The WM_CTLCOLORLISTBOX message is sent to the parent window of a list box before the system draws the list box. By responding to this message, the parent window can set the text and background colors of the list box by using the specified display device context handle. A window receives this message through its WindowProc function. LRESULT CALLBACK WindowProc(
      HWND hwnd,       // handle to window
      UINT uMsg,       // WM_CTLCOLORLISTBOX
      WPARAM wParam,   // handle to DC (HDC)
      LPARAM lParam    // handle to list box (HWND)
    );
      

  2.   

    m_ctrl.AddString("1");
    m_ctrl.AddString("2");
    m_ctrl.AddString("3");
    m_ctrl.AddString("4"); m_ctrl.SetCurSel(2);
      

  3.   

    改变颜色重载OnCtrlColor虚函数
    改变listctrl选择项可以用SetItemState
      

  4.   

    list.SetSel(?, TRUE);
    list.SetCurSel(?);
      

  5.   

    CString strd;
    CString sendDir;
    POSITION pos=m_ListSearch.GetFirstSelectedItemPosition();
        strd=m_ListSearch.GetItemText(m_ListSearch.GetNextSelectedItem(pos),NULL);
      

  6.   

    楼上的几位兄弟,我说的是listctrl,不是listbox
      

  7.   

    加入SelectChanged(0消息,获得行和列,边可以通过上面的 方法改变
      

  8.   

    这个应该可以吧
    http://www.codeguru.com/listview/CListCtrlEx.html