如何通过 点击list控件中的某一列使它传递给 一个修改的对话框
//////////////////////////////////////////////////////////////////////
//功能:弹出修改记录窗口
//日期:2003.12
//////////////////////////////////////////////////////////////////////
void CMainDlg::OnRadioMod()
{
// TODO: Add your control notification handler code here
m_database.Close();//本对话框断开与数据库的连接
CModifyDlg dlg;
dlg.m_database.Open(_T("addresslist"));
int i=m_ctrlperson.GetSelectionMark();
CString strSQL;
int id=atoi(m_ctrlperson.GetItemText(i,0));
CPersonSet m_recordset;
CDBVariant varValue;
if(i==-1)
{
MessageBox("请选择一条要修改的记录!","提示",MB_OK|MB_ICONINFORMATION);
}
else
{
int temp=0;
strSQL.Format("select * from person where ID=%d",id);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
m_recordset.GetFieldValue(temp,varValue);
dlg.m_modid=varValue.m_lVal;
m_recordset.GetFieldValue(1,varValue);
dlg.m_modname=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(2,varValue);
dlg.m_modsex=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(3,varValue);
dlg.m_modrelation=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(4,varValue);
dlg.m_modtelephone=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(5,varValue);
dlg.m_modhandphone=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(6,varValue);
dlg.m_modaddress=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(7,varValue);
dlg.m_modworkplace=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(8,varValue);
dlg.m_modemail=varValue.m_pstring->GetBuffer(1);
m_recordset.GetFieldValue(9,varValue);
dlg.m_modoicq=varValue.m_pstring->GetBuffer(1);
//m_database.Close();//此处不能断开与数据库的连接
dlg.DoModal();
RefreshData();
}
}
void CMainDlg::RefreshData()
{
//首先确保数据库打开
if(!m_database.IsOpen())
{
m_database.Open(_T("addresslist"));
}
//对列表控件的内容更新,清空原来的内容
m_ctrlperson.DeleteAllItems();
//创建记录集
CPersonSet m_personset(