组合框的属性编辑里有Data 这一栏。里面可以输入你要的数据用ctrl+enter换行
先设置一下组合框的属性为dropdown ,ownerDraw为none.
在程序里是这样设置数据,例如:
CComboBox m_Cbo;
m_Cbo.InitStorage(4, 10);//4是说明你要加4行
m_Cbo.AddString("hehe");
m_Cbo.AddString("huhu");
.....
先设置一下组合框的属性为dropdown ,ownerDraw为none.
在程序里是这样设置数据,例如:
CComboBox m_Cbo;
m_Cbo.InitStorage(4, 10);//4是说明你要加4行
m_Cbo.AddString("hehe");
m_Cbo.AddString("huhu");
.....
解决方案 »
- MFC中非模态对话框Create实现原理(SDK编程实现方法)
- BCB编写多线程高速采集程序 遇到麻烦 请各位高手大哥指点一下 在线等
- WTL 自绘制控件的问题,谢谢。
- tree control问题 请前辈们指点
- 打算通读MSDN,请教如何下手?
- 如何实现右击树控件某项,在弹出的菜单中选择"重命名"后实现NM_BEGINLABELEDIT和NM_ENDLABELEDIT那样的编辑功能?
- COM组件错误信息...
- 如何让about dialog中的版本信息自动升级?
- 局域网的问题
- 老大!那里找DDK的资料,除了MSDN?
- 《Inside VC++(第五版)》中关于扩展组合框(ComboBoxEX)的问题
- 在VC6。0中,如何在状态栏上加入按钮,在CTOOLBAR上加入组合框
->AddString("...");
->AddString("...");
键盘太差
2。进入ClassWizard
3.进入变量一项,选择新创建的控件的ID,双击,写变量名,如m_mygroup;
4。然后用m_mygroup.AddString("..."),就可以把字符串加进去了。
5。想在字符串里显示默认得字符串用m_mygroup.SelectString(-1,"...");
6.一切OK;
{
public:
CComboBox m_wndMyComboBox;
}; 注意要将代码放在工程文件mainframe.h中“#endif // _MSC_VER > 1000”语句之后,类CMainFrame定义之前。 4. 将工程文件mainframe.h中的CToolBar变量m_wndToolBar用CMyToolBar变量m_wndToolBar代替。同时增加函数CreateMyComboToolBar()声明。代码如下: protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CMyToolBar m_wndToolBar;
int CreateMyComboToolBar();5. 在工程文件mainframe.cpp中的OnCreate()函数返回语句之前调用函数CreateMyToolBar();代码如下所示: if(!CreateMyComboToolBar())
MessageBox("Create My Combo ToolBar Failure");6. 以文本方式打开资源头文件resource.h,增加一个控制ID如下,注意该控制的ID值不要与其它控制或资源的ID值重复: #define IDC_MY_COMBO 1111 7. 在工程文件mainframe.cpp中增加函数CreateMyToolBar();代码如下: int MainFrame::CreateMyToolBar()
{
#define COMBO_BOX_WIDTH 80 //the width of the combo box
//set up the ComboBox control as a select box
//First get the index of the button's
position in the toolbar
int index = 0;
CRecr rect;
while(m_wndToolBar.GetItemID(index)!
= ID_MY_COMBO_BOX) index++;
//next convert that button to a
seperator and get its position
m_wndToolBar.SetButtonInfo(index,
ID_MY_COMBO_BOX, TBBS_SEPARATOR, COMBO_BOX_WIDTH);
m_wndToolBar.GetItemRect(index, &rect);
//expand the rectangle to allow the
combo box room to drop down
rect.top+=2;
rect.bottom += 200;
// then .Create the combo box and show it
if (!m_wndToolBar.m_ wndMyComboBox.Create(
WS_CHILD|WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_DROPDOWNLIST | CBS_HASSTRINGS ,
rect, &m_wndToolBar, IDC_MY_COMBO))
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
m_wndToolBar.m_wndMyComboBox.ShowWindow(SW_SHOW);
//adding string to the combo box
m_wndToolBar.m_wndMyComboBox.AddString("Fisrt Select");
m_wndToolBar.m_wndMyComboBox.AddString("Second Select");
m_wndToolBar.m_wndMyComboBox.AddString("Third Select");
m_wndToolBar.m_wndMyComboBox.AddString("Fourth Select");
m_wndToolBar.m_wndMyComboBox.AddString("Fifth Select");
m_wndToolBar.m_wndMyComboBox.SetCurSel(0);
}