I have a listctrl in my program, which has two columns that are populated with lots of elements. When the user clicks on one of them with a right click, I would like to know in which of the two columns the element lives.
My problem - the GetColumn() function returns either -1 (aka not found) or a zero -> even due I clicked in the second column (which should be 1 - they start from 0).
I had a look at the sample/listctrl but even there, GetColumn() always returns a 1 even if i click in another column.
I use wxWidgets 2.9.5 on Windows 7.
Here the code that i thought should work but doesn't:
Connect(ID_LISTBOX,wxEVT_LIST_ITEM_RIGHT_CLICK,wxListEventHandler(X::OnRightClick));
....
void X::OnRightClick(wxListEvent& event)
{
int a = event.GetColumn(); // returns - 1 aka not found
int b = wxListItem(event.GetItem()).GetColumn(); // returns zero regardless of the column
event.Skip();
}
How do I find out which column my element is in?
Thanks
GetColumn()only works forEVT_LIST_COL_XXXevents, i.e. clicking on the column itself, as explicitly mentioned in the documentation. For the item clicks you need to explicitly call HitTest() and examine its return value andptrSubItemoutput parameter value.