首页技术radiobutton控件?音频应用audiobar

radiobutton控件?音频应用audiobar

编程之家2026-06-041106次浏览

大家好,今天给各位分享radiobutton控件的一些知识,其中也会对音频应用audiobar进行解释,文章篇幅可能偏长,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在就马上开始吧!

radiobutton控件?音频应用audiobar

Delphi中如何把RadioButton分组

设计 Windows窗体 RadioButton控件是为了使用户可以从两种或多种设置中进行选择(只能将其中一种设置分配给某个过程或对象)。例如,一组 RadioButton控件可以显示一组可供选择的货物运输工具,但只能使用其中的一种工具。因此,每次只能选择一个 RadioButton,即使它是功能组的一部分也不例外。

在一个容器(如 Panel控件、GroupBox控件或窗体)内绘制单选按钮即可将它们分组。直接添加到一个窗体中的所有单选按钮将形成一个组。若要添加不同的组,必须将它们放到面板或分组框中。有关面板或分组框的更多信息,请参见 Panel控件概述(Windows窗体)或 GroupBox控件概述(Windows窗体)。

将 RadioButton控件分组使之独立于其他组工作:

1、从“工具箱”的“Windows窗体”选项卡中,将 GroupBox或 Panel控件拖到窗体上。

2、在 GroupBox或 Panel控件上绘制 RadioButton控件。

C#中radiobutton选中的文本怎么获取

在 C#中获取 RadioButton控件选中的文本,可以通过以下代码实现:

radiobutton控件?音频应用audiobar

在以上示例中,我们首先检查每个 RadioButton是否被选中。如果某个 RadioButton被选中,我们就可以使用 Text属性来获取它的文本,并将其存储到一个字符串变量中。

注意,以上示例中的 radioButton1和 radioButton2是两个示例 RadioButton控件的名称,您需要将其替换为您应用程序中实际使用的控件名称。

vb.net入门之分组控件:GroupBox控件

我们对控件进行分组的原因不外乎三个

为了获得清晰的用户界面而将相关的窗体元素进行可视化分组

编程分组如对单选按钮进行分组

为了在设计时将多个控件作为一个单元来移动

radiobutton控件?音频应用audiobar

在中有GroupBox Panel TabControl这三个控件可以实现上面所提到的三个分组目的所以我们称它们为分组控件

这三个控件在功用上十分的相似特别是GroupBox和Panel控件只存在一点细微的差别而已(这个差别是只有GroupBox控件可以显示标题而只有Panel控件可以有滚动条)这里我们就先来了解GroupBox控件的使用

GroupBox(控件组)控件一般是作为其他控件的组的容器的形式存在的这样有利于用户识别使界面变得更加友好(GroupBox控件相当于Visual Basic以前版本的Frame控件)使用控件组控件可以将一个窗体中的各种功能进一步进行分类例如将各种选项按钮控件分隔开

当移动单个GroupBox控件时它所包含的所有控件也将一起移动

在大多数情况下对控件组控件没有实际的操作我们用它对控件进行分组通常没有必要响应它的事件不过它的Name Text和Font等属性可能会经常被修改以适应应用程序在不同阶段的要求

GroupBox控件在工具箱中的图标如图所示

一 GroupBox控件的常用属性

Anchor和Dock这两个属性是所有有用户界面的控件都有的定位属性这里就不啰嗦了

Name属性标识控件的对象名称

Text属性显示在GroupBox控件右上方的标题文字可以用来标识该控件组的描述

Font和ForeColor属性用于改变GroupBox控件的文字大小以及文字的颜色需要注意的时候它不单改变GroupBox控件的Text属性的文字外观同时也改变其内部控件的显示的Text属性的文字外观

二创建一组控件

在窗体上放置GroupBox控件从工具箱中拖放一个GroupBox控件到窗体上的合适位置调整大小

在属性窗口中改变GroupBox控件的Text属性作为它的标题

在GroupBox控件内拖放其它需要的控件例如RadioButton控件

设置示例如图一所示

图一用控件组控件对单选按钮分组

我们在拖动单个GroupBox控件的时候它内部的控件也会随着移动以保持和GroupBox的相对位置不变同理删除GroupBox控件时它所包含的所有控件也会被删除掉

当我们调整GroupBox控件所包含的控件的Anchor和Dock属性的时候其参照物将不是Form窗体而是GroupBox控件了

三编程添加GroupBox控件以及它所包含的控件

虽然GroupBox控件是在设计时用视图设计布局效果最好但是无可避免地很多特殊情况下也是需要在运行做添加控件到控件组中的这里我们就用代码来完成上图一界面的绘制

动态添加控件一般需要经过下面三个步骤

创建要添加的控件实例

设置新控件的属性

将控件添加到父控件的 Controls集合

在Form代码的任意位置增加初始化控件的过程InitializeControl()代码如下所示

Sub InitializeControl()

首先添加Label和TextBox控件

Dim Label As New System Windows Forms Label

Dim TextBox As New System Windows Forms TextBox

Label

Label Location= New System Drawing Point()

Label Name= Label

Label Size= New System Drawing Size()

Label TabIndex=

Label Text=户主姓名

TextBox

TextBox Location= New System Drawing Point()

TextBox Name= TextBox

TextBox Size= New System Drawing Size()

TextBox TabIndex=

TextBox Text=

把它们添加到父控件Form的Controls集合中

Me Controls Add(TextBox)

Me Controls Add(Label)

添加三个GroupBox控件

Dim GroupBox As New System Windows Forms GroupBox

Dim GroupBox As New System Windows Forms GroupBox

Dim GroupBox As New System Windows Forms GroupBox

GroupBox

GroupBox BackColor= System Drawing SystemColors Control

GroupBox Location= New System Drawing Point()

GroupBox Name= GroupBox

GroupBox Size= New System Drawing Size()

GroupBox TabIndex=

GroupBox TabStop= False

GroupBox Text=性别

GroupBox

GroupBox Location= New System Drawing Point()

GroupBox Name= GroupBox

GroupBox Size= New System Drawing Size()

GroupBox TabIndex=

GroupBox TabStop= False

GroupBox Text=单元

GroupBox

GroupBox Location= New System Drawing Point()

GroupBox Name= GroupBox

GroupBox Size= New System Drawing Size()

GroupBox TabIndex=

GroupBox TabStop= False

GroupBox Text=楼层

把它们添加到父控件Form的Controls集合中

Me Controls Add(GroupBox)

Me Controls Add(GroupBox)

Me Controls Add(GroupBox)

添加RadioButton控件并分别绘制在GroupBox控件内

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=男性

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=女性

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=二单元

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=三单元

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=一单元

RadioButton

RadioButton BackColor= System Drawing SystemColors Control

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=四单元

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=二楼

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=三楼

RadioButton

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=一楼

RadioButton

RadioButton BackColor= System Drawing SystemColors Control

RadioButton Location= New System Drawing Point()

RadioButton Name= RadioButton

RadioButton Size= New System Drawing Size()

RadioButton TabIndex=

RadioButton Text=四楼

分别把它们添加到父控件GroupBox的Controls集合中

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

GroupBox Controls Add(RadioButton)

End Sub

把上一页的代码复制添加后把控件初始化过程InitializeControl()过程添加到Form的New构造函数中如下图二所示

图二在New构造函数中添加过程InitializeControl()

现在按F运行 Form的窗体控件布局(如下图三所示)是不是和我们手工布局的图一的布局是一样的呢?

lishixinzhi/Article/program/ASP/201311/21749

关于radiobutton控件,音频应用audiobar的介绍到此结束,希望对大家有所帮助。

魔兽世界国服官网,魔兽世界商城自定义滚动条 移动端滚动条