Combox SetItemData索引与数据绑定
2009-10-26 13:41
435 查看
1. 数据结构
typedef struct PartType_s
{
CString KeyValue;
CString KeyIndex;
}PartType_t;
2.初始化数据
while(!m_pRecordset->adoEOF)
{
// _variant_t vIndex = (long)0;
//_variant_t vCount = m_pRecordset->GetCollect(vIndex);
UpdateData();
PartType_t *mPartType=new PartType_s;
mPartType->KeyValue=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Name");
mPartType->KeyIndex=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ID");
lvItemIndex=m_com_team_a.AddString(mPartType-> KeyValue);
m_com_team_a.SetItemData(lvItemIndex,(DWORD)mPartType);
lvItemIndex=m_com_team_b.AddString(mPartType-> KeyValue);
m_com_team_b.SetItemData(lvItemIndex,(DWORD)mPartType);
UpdateData(false);
m_pRecordset->MoveNext();
}
3.select
int sel = m_com_team_a.GetCurSel();
PartType_t * mPartType = NULL; //=new PartType
mPartType = (PartType_t*)m_com_team_a.GetItemData(sel);
CString NameA=mPartType->KeyValue;
int IdxA=atoi(mPartType->KeyIndex);
typedef struct PartType_s
{
CString KeyValue;
CString KeyIndex;
}PartType_t;
2.初始化数据
while(!m_pRecordset->adoEOF)
{
// _variant_t vIndex = (long)0;
//_variant_t vCount = m_pRecordset->GetCollect(vIndex);
UpdateData();
PartType_t *mPartType=new PartType_s;
mPartType->KeyValue=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Name");
mPartType->KeyIndex=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ID");
lvItemIndex=m_com_team_a.AddString(mPartType-> KeyValue);
m_com_team_a.SetItemData(lvItemIndex,(DWORD)mPartType);
lvItemIndex=m_com_team_b.AddString(mPartType-> KeyValue);
m_com_team_b.SetItemData(lvItemIndex,(DWORD)mPartType);
UpdateData(false);
m_pRecordset->MoveNext();
}
3.select
int sel = m_com_team_a.GetCurSel();
PartType_t * mPartType = NULL; //=new PartType
mPartType = (PartType_t*)m_com_team_a.GetItemData(sel);
CString NameA=mPartType->KeyValue;
int IdxA=atoi(mPartType->KeyIndex);
相关文章推荐
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem的具体分析
- combox 绑定数据后增加item
- WPF数据绑定(ItemTemplate和DataTemplate)
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem几种方式与用法分析
- 数据绑定以及Container.DataItem几种方式与用法分析
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem几种方式与用法分析 .
- 数据绑定以及Container.DataItem几种方式与用法分析
- 数据绑定以及Container.DataItem绑定技巧
- MFC Combox SetItemData与GetItemData使用实例
- combox 绑定数据后增加item
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem几种方式与用法分析
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem的具体分析
- 数据绑定以及Container.DataItem几种方式与用法分析