views:

497

answers:

2

I want to select a particular column in a ListView. When I search for it I always find ways to select row-wise only. Any idea how do I do it? Also how do I get the selected column index?

Using MFC-VS2005.

+1  A: 

There's a CListCtrl::SetSelectedColumn() method that looks like it does what you want: it posts an LVM_SETSELECTEDCOLUMN message to the list view control.

Similarly, CListCtrl::GetSelectedColumn() gets the selected column.

DavidK
+1  A: 

I'm maintaining a VS6.0 app that I've ported to VS 2005, and SetSelectedColumn isn't available in CListCtrl unless _WIN32_WINNT >= 0x0501. Mine was 0x400 & I couldn't understand at first why using SetSelectedColumn caused a compiler error. see commctrl.h for details

andywebsdale