关于VC++的问题。请高手帮忙解决!!!!
下面是我的代码,大家都知道这是对列表控件赋值。可是,在运行后,只是对第一列赋值,其余列仍为空。这是为什么?请大家帮忙解决!!谢谢!!voidCPresonAddapply...
下面是我的代码,大家都知道这是对列表控件赋值。可是,在运行后,只是对第一列赋值,其余列仍为空。这是为什么?请大家帮忙解决!!谢谢!!
void CPresonAddapplyDlg::RefreshData()
{
m_ctrList.DeleteAllItems();
m_ctrList.SetRedraw(FALSE);
//UpdateData(TRUE);
CString strSQL;
CString strValue;
strSQL="select * from combopersoninfo";
if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return ;
}
int i=0;
while(!m_recordset.IsEOF())
{
if(m_recordset.m_isadd)
{
//学号
m_recordset.GetFieldValue("stunum",strValue);
m_ctrList.InsertItem(i,strValue);
//姓名
m_recordset.GetFieldValue("name",strValue);
m_ctrList.SetItemText(i,1,strValue);
//班级
m_recordset.GetFieldValue("class",strValue);
m_ctrList.SetItemText(i,2,strValue);
//班级代码
m_recordset.GetFieldValue("classcode",strValue);
m_ctrList.SetItemText(i,3,strValue);
//系别
m_recordset.GetFieldValue("department",strValue);
m_ctrList.SetItemText(i,4,strValue);
//加分分值
m_recordset.GetFieldValue("add",strValue);
m_ctrList.SetItemText(i,5,strValue);
//加分时间
m_recordset.GetFieldValue("addtime",strValue);
m_ctrList.SetItemText(i,6,strValue);
//加分类型
m_recordset.GetFieldValue("addtype",strValue);
m_ctrList.SetItemText(i,7,strValue);
//加分原因
m_recordset.GetFieldValue("addcause",strValue);
m_ctrList.SetItemText(i,8,strValue);
}
i++;
m_recordset.MoveNext();
}
m_recordset.Close();
m_ctrList.SetRedraw(TRUE);
} 展开
void CPresonAddapplyDlg::RefreshData()
{
m_ctrList.DeleteAllItems();
m_ctrList.SetRedraw(FALSE);
//UpdateData(TRUE);
CString strSQL;
CString strValue;
strSQL="select * from combopersoninfo";
if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return ;
}
int i=0;
while(!m_recordset.IsEOF())
{
if(m_recordset.m_isadd)
{
//学号
m_recordset.GetFieldValue("stunum",strValue);
m_ctrList.InsertItem(i,strValue);
//姓名
m_recordset.GetFieldValue("name",strValue);
m_ctrList.SetItemText(i,1,strValue);
//班级
m_recordset.GetFieldValue("class",strValue);
m_ctrList.SetItemText(i,2,strValue);
//班级代码
m_recordset.GetFieldValue("classcode",strValue);
m_ctrList.SetItemText(i,3,strValue);
//系别
m_recordset.GetFieldValue("department",strValue);
m_ctrList.SetItemText(i,4,strValue);
//加分分值
m_recordset.GetFieldValue("add",strValue);
m_ctrList.SetItemText(i,5,strValue);
//加分时间
m_recordset.GetFieldValue("addtime",strValue);
m_ctrList.SetItemText(i,6,strValue);
//加分类型
m_recordset.GetFieldValue("addtype",strValue);
m_ctrList.SetItemText(i,7,strValue);
//加分原因
m_recordset.GetFieldValue("addcause",strValue);
m_ctrList.SetItemText(i,8,strValue);
}
i++;
m_recordset.MoveNext();
}
m_recordset.Close();
m_ctrList.SetRedraw(TRUE);
} 展开
展开全部
列表控件 m_ctlList
初始化:
m_ctlList.SetExtendedStyle(LVS_EX_FULLROWSELECT);//设置列表控件的新扩展风格
CString Field[3]={"表头","第二项","第三项"}; //列表视的表头
for(int j=0;j<3;j++)
{
m_ctlList.InsertColumn(j,Field[j],LVCFMT_LEFT,95); //插入表头标题
}
插入CString类型的字符:
CString a="第一"
m_ctlList.InsertItem(0,a);
m_ctlList.SetItemText(0,1,"第二");
m_ctlList.SetItemText(0,2,"第三");
提交:UpdateData(FALSE);
初始化:
m_ctlList.SetExtendedStyle(LVS_EX_FULLROWSELECT);//设置列表控件的新扩展风格
CString Field[3]={"表头","第二项","第三项"}; //列表视的表头
for(int j=0;j<3;j++)
{
m_ctlList.InsertColumn(j,Field[j],LVCFMT_LEFT,95); //插入表头标题
}
插入CString类型的字符:
CString a="第一"
m_ctlList.InsertItem(0,a);
m_ctlList.SetItemText(0,1,"第二");
m_ctlList.SetItemText(0,2,"第三");
提交:UpdateData(FALSE);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询