MFC如何让DIALOG1中添加数据后点击确定BUTTON后,在DIALOG2里的列表控件里显示刚才新添加的数据,小弟我用的MySQL
MFC怎么让DIALOG1中添加数据后点击确定BUTTON后,在DIALOG2里的列表控件里显示刚才新添加的数据,我用的MySQL?
Test t;
t.m_test.DeleteAllItems();
CString sql1;
sql1 = "SELECT * FROM 表名ORDER BY id DESC LIMIT 1";
DBCon db;
MYSQL_RES * res = db.select(sql.GetBuffer(sql.GetLength()));
int item;
MYSQL_ROW row;
if (NULL != res)
{
while( (row = mysql_fetch_row(res)) != NULL )
{
item = t.m_test.InsertItem(0, row[1]);
t.m_test.SetItemText(item, 1, row[2]);
t.m_test.SetItemText(item, 2, row[3]);
t.m_test.SetItemText(item, 3, row[4]);
t.m_test.SetItemText(item, 4, row[5]);
t.m_test.SetItemText(item, 5, row[6]);
t.m_test.SetItemText(item, 6, row[7]);
t.m_test.SetItemText(item, 7, row[8]);
t.m_test.SetItemText(item, 8, row[9]);
}
}
数据库链接没问题,在同一对话框里也会做,在其他对话框了就不太懂了,数据添加没问题,就是怎么让新数据显示在另一个对话框的列表控件中呢?初学~所以还不能灵活应用,希望懂的人能指点一下我,谢谢!
------解决方案--------------------
自己定个结构,通过句柄,发消息,调函数都行,然后通过你的结构再解析出来,显示就行了。
------解决方案--------------------
1.DIALOG1中想办法获得DIALOG2对象的指针,然后在1中直接操作2
2.DIALOG1发送消息告诉2需要更新,同时将查询结果的(引用或者指针)传给2
Test t;
t.m_test.DeleteAllItems();
CString sql1;
sql1 = "SELECT * FROM 表名ORDER BY id DESC LIMIT 1";
DBCon db;
MYSQL_RES * res = db.select(sql.GetBuffer(sql.GetLength()));
int item;
MYSQL_ROW row;
if (NULL != res)
{
while( (row = mysql_fetch_row(res)) != NULL )
{
item = t.m_test.InsertItem(0, row[1]);
t.m_test.SetItemText(item, 1, row[2]);
t.m_test.SetItemText(item, 2, row[3]);
t.m_test.SetItemText(item, 3, row[4]);
t.m_test.SetItemText(item, 4, row[5]);
t.m_test.SetItemText(item, 5, row[6]);
t.m_test.SetItemText(item, 6, row[7]);
t.m_test.SetItemText(item, 7, row[8]);
t.m_test.SetItemText(item, 8, row[9]);
}
}
数据库链接没问题,在同一对话框里也会做,在其他对话框了就不太懂了,数据添加没问题,就是怎么让新数据显示在另一个对话框的列表控件中呢?初学~所以还不能灵活应用,希望懂的人能指点一下我,谢谢!
------解决方案--------------------
自己定个结构,通过句柄,发消息,调函数都行,然后通过你的结构再解析出来,显示就行了。
------解决方案--------------------
1.DIALOG1中想办法获得DIALOG2对象的指针,然后在1中直接操作2
2.DIALOG1发送消息告诉2需要更新,同时将查询结果的(引用或者指针)传给2