C# WinForms 单选按钮

标签 c#

我加载了 4 个单选按钮,当我运行程序并单击它们时,如果我单击一个,然后单击另一个,其他按钮就会消失。如果我想有两个单选按钮但它们做不同的事情怎么办?

最佳答案

将不同的选择集分组到单独的组框(或面板,或其他容器控件,但组框可能是您想要的)。

MSDN :

Windows Forms RadioButton controls are designed to give users a choice among two or more settings, of which only one can be assigned to a procedure or object. For example, a group of RadioButton controls may display a choice of package carriers for an order, but only one of the carriers will be used. Therefore only one RadioButton at a time can be selected, even if it is a part of a functional group.

You group radio buttons by drawing them inside a container such as a Panel control, a GroupBox control, or a form.

假设您的表单上有四个或更多单选按钮。例如,如果您只有两个,并且您希望允许用户同时选择两个,请使用一组复选框。

关于C# WinForms 单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3851765/

相关文章:

c# - Linux VPS 上的单声道垃圾收集

c# - 如何隐藏静态方法

c# - 在 C# 中播放部分声音 (WMA) 文件

c# - 停止播放通过 SoundEffect.FromStream 调用的声音

c# - 我可以根据 .NET Framework 版本创建预处理器指令吗?

c# - 如何使用数据库优先方法读取 asp.net core 中的表

c# - 你能把两个数字相加吗,就好像它们是正数一样,即使它们可能是负数

vsto - 这个 Excel VBA 代码的 C# 等价物是什么?

c# - Net Core app.UseMiddleware<T>() 和 app.Use(context, next) 之间的区别

c# - .NET FileSystemWatcher 检测 NTFS 安全变化