我做程序用到两个组合框,一个用来显示用户代号,一个用来显示姓名,我选择用户代号的那个组合框,显示姓名的那个组合框自动显示相应的姓名,但在vc中确发现慢了一拍,我用的是selchanged事件,即我选择这一个,他提示我选择的上一个,不同步
解决方案 »
- 还是prepertysheet隐藏page问题
- BitBlt咋实现的,速度这快?
- 先把话放到这,专利和知识产权最终会成为闹剧,它们将在不远的未来消失
- 请教一个Access数据库的问题,关于_ConnectionPtr
- 高分!!!求如何改变edit控件显示的角度
- DirectShow应用程序调试的问题
- htttp编程时,服务器老是连接不上,是不是头有问题?
- 500分急求miscrosoft odbc 3.0 sdk.
- DLL的问题,谁是真正的高手?
- Gina与USBKey 系列问题之五
- 动态库共享数据段的变量值是可动态改变的吗?
- 100分,如何利用tcp中的时间戳选项求网络的往返时延?急急急!!!
void CInputgoods::OnSelchangeuseid()
{
CString str1,str2; UpdateData(true);
if (m_userid.GetLength()<=0)
{
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_useid);
pEdit->SetFocus ();
return;
}
CString sql="select userID from alluser where name='" +m_userid+"' ";
// AfxMessageBox(sql);
try
{
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
if(m_pRecordset->adoEOF)
{ AfxMessageBox("你的数据库中还没有此商品"); //AfxMessageBox("你的数据库中还没有记录信息!");
}
else
{
while(!m_pRecordset->adoEOF)
{
m_id.InsertString(0,(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("userID"));
str1=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("userID");
m_pRecordset->MoveNext();
}
// AfxMessageBox(str1);
SetDlgItemText(IDC_COMBO1,str1);
}
m_pRecordset->Close();
}
catch(_com_error e)///捕捉异常
{
CString temp;
temp.Format("连接数据库错误信息:%s",e.ErrorMessage());
AfxMessageBox(temp); // return false;
}
}
m_userid是什么?如果是序号,试试
CString sql="select userID from alluser where name='" +(m_userid+1)+"' ";
SetDlgItemText(IDC_COMBO1,str1);
这个AfxMessageBox打出来的是正确的吗?
你是在数据库中取数据,为什么不用一个编辑框显示呢
你肯定是把它定义为CString的,原因在于,现在m_userid并没有更新到新值啊
只是你刚刚选择玩啊:)
你可以这样做啊把那个控件加一个CComboBox m_ctrlUserId;CString strTemp;m_ctrlUserId.GetLBText(m_ctrlUserId.GetCurSel(),strTemp);这样就可以了阿strTemp就是你要用的那个东东阿!!:)