saving list control data in a string
-
I'm working on a list control application. When i double click on a row, i want to save the data in the 3rd column of that selected row to be store in a string. Please tel me know how can this be achieved. Thanks in Advance
You can do that using the
CListCtrl
class The following member functions need to be used -GetFirstSelectedItemPosition GetNextSelectedItem GetItemText
«_Superman_»
-
I'm working on a list control application. When i double click on a row, i want to save the data in the 3rd column of that selected row to be store in a string. Please tel me know how can this be achieved. Thanks in Advance
// Map double click using event handling ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CListSampleDlg::OnNMDblclkList) // in the callback function
void CListSampleDlg::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR);// Get 3rd item's text. CString str = m\_List.GetItemText( pNMItemActivate->iItem, 2 ); AfxMessageBox( str ); \*pResult = 0;
}
is this what you want?
-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts
-
// Map double click using event handling ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CListSampleDlg::OnNMDblclkList) // in the callback function
void CListSampleDlg::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR);// Get 3rd item's text. CString str = m\_List.GetItemText( pNMItemActivate->iItem, 2 ); AfxMessageBox( str ); \*pResult = 0;
}
is this what you want?
-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts
Thank you for the code. Though it wasn't working I got an idea and completed the required one. But if i want to save the data of the 3rd column in a string of about more than one selected rows with "|" as separator. Please let me know how can this achieved. Thanks in advance
-
Thank you for the code. Though it wasn't working I got an idea and completed the required one. But if i want to save the data of the 3rd column in a string of about more than one selected rows with "|" as separator. Please let me know how can this achieved. Thanks in advance
I believe Superman already given you idea on getting text of selected items. Here's the code snippet. Please check MSDN.It contains lot of sample snippet with documentation
CString strColumText;
POSITION pos = m_List.GetFirstSelectedItemPosition();
if (pos == NULL)
{
TRACE(_T("No items were selected!\n"));
}
else
{
while (pos)
{
int nItem = m_List.GetNextSelectedItem(pos);
strColumText += _T("|") + m_List.GetItemText( nItem, 2 );
}
}-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts