Home > Software engineering > ListCtrl control after the double-click unable to get the line number in addition to the first colum
ListCtrl control after the double-click unable to get the line number in addition to the first colum
Time:10-01
ListCtrl control after the double-click unable to get the line number in addition to the first column Function is online most of the people use example: (can only get to the line and column number in the first column, click on the second column is always display line Numbers to 1)
void ParaMeterTool: : OnDblclkList1 (NMHDR * pNMHDR, LRESULT * pResult) { LPNMITEMACTIVATE pNMItemActivate=reinterpret_cast & lt; LPNMITEMACTIVATE> (pNMHDR); //TODO: add the control notification handler code /* if (pNMItemActivate - & gt; IItem!=1) */ Listitemdbcl=list_meterdata. GetSelectionMark (); If (listitemdbcl) { CRect the rect, dlgRect; //get the current column width to fit if the user adjust the width of the Int width=list_meterdata. GetColumnWidth (pNMItemActivate - & gt; The iSubItem); List_meterdata. GetSubItemRect (listitemdbcl pNMItemActivate - & gt; LVIR_BOUNDS iSubItem, the rect);
//save selection list items index //this because two lists public a CEdit control //so you need to save the list of index //as well as the corresponding item category index no.Listdbclicked=1; /* listitemdbcl=pNMItemActivate - & gt; IItem. */ Listsubitemdbcl=pNMItemActivate - & gt; The iSubItem; } * pResult=0; }
Can't directly obtained with pNMItemActivate, use GetSelectionMark () function also can not get the number of rows in the second column,, The programming of the listctrl is that there is nothing wrong with watching!
int line=list_meterdata. GetItemCount (); Str_list. The Format (_T (" % 0.2 f), flow_s); List_meterdata. InsertItem (line, str_list); For (I=0; I{ Str_list. The Format (_T (" % d "), dt [I]); List_meterdata. SetItemText (line, I + 1, str_list); }