#单选按钮是否有限制 [英] Is there a limit on # of radio buttons

查看:63
本文介绍了#单选按钮是否有限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows窗体上有8个单选按钮,但我只能选择最后的

4.如果我点击第4个以外的任何按钮然后再回到

程序再次第4个按钮总是被检查而不是第5个或第6个

等我通过调试器跟踪逻辑并且可以看到第5个按钮在哪里

是以编程方式检查的,但窗口显示第4个已检查。

有没有人知道这里发生了什么?所有单选按钮

都在一个组合框中。

Dave

I have 8 radio buttons on my Windows form but I can only select up to the
first 4. If I click on any button beyond the 4th one and then come back into
the program again the 4th button is always checked instead of the 5th or 6th
etc. I followed the logic thru the debugger and can see where the 5th button
is progammatically checked but the window shows the 4th checked instead.
Does anyone have a clue as to what''s going on here? All of the radio buttons
are in a group box.
Dave

推荐答案

鹦鹉写道:
Parrot wrote:

我的Windows窗体上有8个单选按钮,但我只能选择最后的

4.如果我点击超过第4个按钮的任何按钮然后再回到

程序中第4个按钮总是被检查而不是第5个或第6个

等我通过逻辑通过调试器,并可以看到第5个按钮

在哪里被编程检查,但窗口显示第4个已检查。

有没有人知道这里发生了什么?所有单选按钮

都在一个组合框中。

Dave
I have 8 radio buttons on my Windows form but I can only select up to the
first 4. If I click on any button beyond the 4th one and then come back into
the program again the 4th button is always checked instead of the 5th or 6th
etc. I followed the logic thru the debugger and can see where the 5th button
is progammatically checked but the window shows the 4th checked instead.
Does anyone have a clue as to what''s going on here? All of the radio buttons
are in a group box.
Dave



如果有限制,它肯定不是四个。更像是

65536或4294967296.


你在哪里存储数据?您是否检查过存储的值是否为
是否正确?


如何在加载数据时选择正确的单选按钮?


-

G ??跑了Andersson

_____
http://www.guffa.com


我使用的逻辑非常简单。加载程序时,我检查了一个

传递的变量。代码如下:


if(dateformat.Compare(" month")== 0)

{

radioButton5.Checked = true;

}


但是,当显示窗口时,它会显示radioButton4,而不是
。我在调试模式下遵循逻辑,这是唯一以编程方式检查的单选按钮
。我不明白这么简单的东西怎么办不行。

戴夫


G ??跑了安德森写道:
The logic I am using is very simple. When loading the program I check a
passed variable. The code goes like this:

if(dateformat.Compare("month") ==0)
{
radioButton5.Checked = true;
}

However, when the window is displayed, it shows radioButton4 checked
instead. I followed the logic in debug mode and that is the only radiobutton
programmatically checked. I don''t understand how something so simple cannot
work.
Dave

"G??ran Andersson" wrote:

Parrot写道:
Parrot wrote:

我的Windows窗体上有8个单选按钮,但我只能首先选择

4.如果我点击第4个以外的任何按钮,然后再回到

程序,第4个按钮总是被检查而不是5号或6号

等我通过调试器跟踪逻辑,可以看到第5个按钮

在哪里被逐步检查,但是窗口显示第4个已检查。

有没有人知道这里发生了什么?所有单选按钮

都在一个组合框中。

Dave
I have 8 radio buttons on my Windows form but I can only select up to the
first 4. If I click on any button beyond the 4th one and then come back into
the program again the 4th button is always checked instead of the 5th or 6th
etc. I followed the logic thru the debugger and can see where the 5th button
is progammatically checked but the window shows the 4th checked instead.
Does anyone have a clue as to what''s going on here? All of the radio buttons
are in a group box.
Dave



如果有限制,它肯定不是四个。更像是

65536或4294967296.


你在哪里存储数据?您是否检查过存储的值是否为
是否正确?


如何在加载数据时选择正确的单选按钮?


-

G ??跑了Andersson

_____
http://www.guffa.com


" Parrot" < Pa **** @ discussion.microsoft.com写信息

新闻:AA ************************ ********** @ microsof t.com ...
"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:AA**********************************@microsof t.com...

>

然而,当窗口是显示,它显示radioButton4已检查

而不是。我在调试模式下遵循逻辑,这是唯一以编程方式检查的

radiobutton

。我不明白怎么这么简单

不能工作。

Dave
>
However, when the window is displayed, it shows radioButton4 checked
instead. I followed the logic in debug mode and that is the only
radiobutton
programmatically checked. I don''t understand how something so simple
cannot
work.
Dave



VB6 dev这里,所以dotNet单选按钮可能已经改变了(但是我怀疑它,因为它们在VB3 / NT3.51中与VB6 / XP中的相同) ..他们并不像他们看起来那样易于使用。


因为他们改为真。当他们获得焦点时,无论如何,你必须在隐藏/显示/禁用/启用它们之前确保一些事情。我见过(并广泛使用)的最简单的方法是禁用他们的

容器,直到焦点在你想要的位置。


例如...如果Button3'当前= True,但是当你的表单显示(或

你启用/禁用控件)时,第一个获得焦点的控制是

Button5,Button5将设置= True,无论如何。因此,禁用

容器会将重点放在其他地方,从而防止出现此问题...因为我的

应用程序控制硬件并在洁净室中使用,我们不允许专注于

坚持一个控制器可能会导致移动...太多的人可以

走上去,靠在键盘等等......所以,我通常会把一个图片放在上面

表单,设置其background = form'的背景并将焦点设置为。

由于图片框没有显示焦点矩形,并且

在你的情况下,也许你有一个文本框或命令按钮,用于设置焦点,

而不是......无论如何,你可能会找到你的胭脂收音机

按钮。保持设置本身=真的是在没有你的b / b
参与的情况下获得焦点..

VB6 dev here, so dotNet Radio buttons may''ve changed (but I doubt it, since
they were the same in VB3/NT3.51 as they are in VB6/XP).. They''re not as
easy to work with as they seem.

Since they change to "True" when they get focus, no matter what, you have to
make sure of a few things before hiding/showing/disabling/enabling them. The
simplest method I''ve seen (and used extensively) is to disable their
container until focus is where you''d like it to be.

For example... if Button3''s currently = True, but when your form shows (or
you''re enabling/disabling controls), the first control that gains focus is
Button5, Button5 will be set = True, no matter what. So, disabling the
container forces focus elsewhere, which prevents this problem... since my
apps control hardware and are used in the cleanroom, we don''t allow focus to
"stick" to a control that may cause something to move... too many people can
walk up and lean on the keyboard, etc.... so, I usually drop a picturebox on
the form, set its background = form''s background and set focus to that.
Since the picturebox doesn''t show a focus rectangle, and there''s no code in
its click event, people can lean on the keyboard all they want without
worry.

In your case, maybe you have a textbox or command button to set focus to,
instead.... what ever the case, you''ll probably find your "rouge radio
button" that keeps setting itself = true is getting focus without your
involvement..


这篇关于#单选按钮是否有限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆