void MyFrame::OnListItemSelected(wxListEvent& event) { int rowIndex = event.GetIndex(); int colIndex = event.GetColumn(); // Get the associated wxListCtrl control wxListCtrl* listCtrl = event.GetEventObject(); // Get the selected item's text in column 1 wxString itemText = listCtrl->GetItemText(rowIndex, 1); // Update the item's text in column 2 listCtrl->SetItem(rowIndex, 2, itemText); }
void MyFrame::OnListColumnHeaderClick(wxListEvent& event) { int colIndex = event.GetColumn(); wxString message = wxString::Format("Column index: %d", colIndex); wxMessageBox(message, "Column Clicked", wxOK | wxICON_INFORMATION, this); }This code snippet shows how to display the index of a clicked column in a message box. The GetColumn() function is used to retrieve the column index from the wxListEvent object passed to the event handler function. Package/Library: wxWidgets Library.