HELP!MFC,Why I can't get List Control's values

kanch96

Solid State Member
Messages
18
Location
China
Thank you have time to see this post
I have a function,
I hope it can achieve to read each line of the specified List Control column values​​,
I refer to the MSDN, he suggest to use this function: CString GetItemText (int nItem, int subItem);
But after I spent no response, or lack of value, how is this going?


Source code is as follows:
notes:md_dataLC is List Control's variable

Code:
void CICDlg::OnBnClickedButtonChange()
{
//得到被选中项索引
	CString ALL="",MID="",VALUE[4];
	int Where = md_dataLC.GetSelectionMark();
	for(int i = 0;i<4;i++)
	{
		VALUE[i] = md_dataLC.GetItemText(Where,i);    [COLOR="Blue"]//←this doesn't work,what's wrong?[/COLOR]
	}
	ALL = Value[0]+"$"+Value[1]+"$"+Value[2]+"$"+Value[3];
MessageBox(ALL,"来自ICDlg");
//准备交换数据
	CFile ff;
	char all[9999];
	ff.Open("C:\\bufferofCA.txt",CFile::modeReadWrite);
//写入数据,以便交换
	ff.Write(ALL,ALL.GetLength());
	ff.Close();
//显示修改对话框
	AddNewItemDlg dlg;
	dlg.DoModal();
//读取数据
	CFile f;
	f.Open("C:\\bufferofCA.txt",CFile::modeReadWrite);
	f.Read(all,f.GetLength());
	for(int i= 0;i<f.GetLength();i++)
	{
		ALL+= all[i];
	}
	Value[0] = ALL.Left(ALL.Find("$"));
	MID = ALL.Right(ALL.GetLength()-ALL.Find("$")-1);
	ALL = MID;
	Value[1] = ALL.Left(ALL.Find("$"));
	MID = ALL.Right(ALL.GetLength()-ALL.Find("$")-1);
	ALL = MID;
	Value[2] = ALL.Left(ALL.Find("$"));
	MID = ALL.Right(ALL.GetLength()-ALL.Find("$")-1);
	ALL = MID;
	Value[3] = ALL;
//插入数据
	for(int i = 0;i<4;i++)
	{
		md_dataLC.SetItemText(Where,i,Value[i]);
	}
//更新数据数
	CString buffer;
	int nHeadNum = md_dataLC.GetItemCount();
	buffer.Format("共 %d 条数据",nHeadNum);
	GetDlgItem(MAINDIALOG_STATIC_DOWNTIP)->SetWindowText(buffer);
	f.Close();
}



where is the problem?
 
Back
Top Bottom