vc 中 CheckBox 有时候感觉失效,点击的时候没有选上,打不上勾
来源:互联网 发布:java入门编程实例 编辑:程序博客网 时间:2024/05/01 03:34
vc 中 CheckBox 有时候感觉失效,点击的时候没有选上
在开发中遇到过一次这种问题,点击CheckBox 时,前面总是打不上勾
但是有事件发送下去。
后来比较了一下这个Checkbox 和其他的差别,发现Style属性也重Auto 没有选上。
选上后,一切正常。
====
多方查找该问题, 最好在一篇英文中找到,
http://www.devarticles.com/c/a/Cplusplus/Using-MFC-in-C-Controls-DDX-and-DDV/3/
(Page 4 of 9 )
As with the EDITTEXT control, we create both the check box control within our resource file. Updating our example resource file, we would add a check box, like this:
AUTOCHECKBOX "Able to vote?", IDCB_CANVOTE, 20, 35, 50, 15, WS_VISIBLE | WS_CHILD | WS_TABSTOP
This would add a check box to our dialog box. Its caption would be set to “Able to vote?”. MFC provides two types of check boxes: The CHECKBOX, and the AUTOCHECKBOX control. In our example above, I have used the AUTOCHECKBOX control, simply because if we chose the CHECKBOX control, we would have to handle the checking and un-checking of the box manually, which is just a pain.
The syntax of the CHECKBOX control is shown below:
[AUTO]CHECKBOX [Caption], [Control Id], [X Pos], [Y Pos], [Width], [Height], [Style Options]
The caption of the check box is the text that will be displayed next to the check box. The control id is a numerical id, which is #defined within another header file. In our example, we have used IDCB_CANVOTE. I have prefixed the check box controls id with IDCB, which is representational for “Check Box Identification”. You can, however name your controls id’s whatever you like.
It’s really simple to get and set the value of a check box control. As you can probably guess, a check box is either on or off, 1 or 0. We retrieve the value of our check box control like this:
int checkState;
CButton* pCheck = (CButton*)GetDlgItem(IDCB_CANVOTE);
checkState = pCheck->GetCheck();
As with the EDITTEXT control, we retrieve a reference to the control via its id. The check box control is a member of the CButton class, so we cast it as such. The GetCheck method of the CButton class returns the current value of our check box: 0 for not checked, or 1 for checked.
To set the value of our check box control, we can use the SetCheck method, like this:
CButton* pCheck = (CButton*)GetDlgItem(IDCB_CANVOTE);
pCheck->SetCheck(1);
That’s pretty much all you need to create and use a check box control because they are so simple. Let’s now look at the radio button control.
Using MFC in C++ Part 4: Controls, DDX and DDV - The check box control
原来Auto如果没有选上的话,需要在它的事件里面手动调用
SetCheck()
来给复选框打上勾。
如果选上Auto的话,则系统自己打上勾了。
- vc 中 CheckBox 有时候感觉失效,点击的时候没有选上,打不上勾
- CheckBox 失效,点击的时候没有选上
- 关于有时候GridView的OnItemClickListener点击失效问题
- ListView中适用CheckBox导致OnItemClicklistener点击失效
- listview中增加checkbox导致item点击事件失效
- ListVIew点击事件失效(item中包含checkbox)
- android ListView中有checkbox后item点击事件失效
- ListView条目中有CheckBox点击事件失效问题
- ListView点击没有反应,(其每一项有button或checkbox子控件的时候),解决。。
- UPUPW_NGINX_PHP5.3.29_1504.7z的问题 REQUEST 数字的时候,有时候会失效
- RadioButton 点击时候没有音效的问题
- ListView的item中有button ImageButton CheckBox EditText等时 点击事件失效问题的解决
- ListView的item中有button ImageButton CheckBox EditText等时 点击事件失效问题的解决
- ListView的Item包含checkBox的时候的点击事件
- 解决ListView中有多个Checkbox的时候点击的问题
- scrolloView点击按钮实现滑动的时候有时候会出现卡顿的现象
- VC窗体上的关闭按钮失效
- 点击a标签的时候同时选中checkbox
- 热烈庆祝开博
- jxl导出excel
- Oracle数据库下创建用户并授予权限
- EasyMock: missing behavior definition for the preceeding method call
- jQuery1.4.2与json格式兼容问题
- vc 中 CheckBox 有时候感觉失效,点击的时候没有选上,打不上勾
- 怎样应用Javascirpt中的异常处理机制
- 现在学软件的还没当保安,服务员工资高!!
- 序列化与反序列化操作
- 2010年6月10日俱乐部北京活动,“如何做研发人员绩效管理?”主题研讨活动
- 诺基亚N系旗舰机型全面启用MeeGo 弃用塞班
- study ror
- 时间过得真快
- 西班牙电信力挺MeeGo操作系统