C#-RadioButton,comboBox,生肖查询---ShinePans
Posted shinepans
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C#-RadioButton,comboBox,生肖查询---ShinePans相关的知识,希望对你有一定的参考价值。
程序:
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用System.Windows.Forms的;
命名空间RadioButton_1
静态类节目
/ / /公升; summarygt
/ / /应用程序的主入口点。
/ / / </摘要>
[STAThread]
静态无效的主要()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(假);
Application.Run(新Form1中());
/ /外观确定单选按钮的外观
/ /自动检查指示在单击控件时,经过值和控件的外观是否自动更改
/ / AutoEllipsis指示是否在控件的右边缘显示省略号(...)以表示空间超出文本范围
/ / CheckAlign的RadioButton的复选框部分位置
/ / Checkde是否已选中控件
/ /文本关联的文本
/ /文本对齐单选按钮控件上的文本对齐方式
/ /的CheckedChanged当检查属性值更改时发生
/ /生肖框用组框控件完成
Form1.cs中
使用系统;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Drawing;
使用System.Linq的;
使用System.Text;
使用System.Windows.Forms的;
命名空间RadioButton_1
公共部分Form1类:表
公用Form1()
的InitializeComponent();
私人无效Form1_Load(对象发件人,EventArgs的发送)
/ /为年份下拉列表赋值
为(int i = 1900; I <= 2050,我+ +)
comboBox1.Items.Add(ⅰ);
comboBox1.Text = DateTime.Now.Year.ToString();
私人无效comboBox1_SelectedIndexChanged(对象发件人,EventArgs的发送)
整型intYear = Convert.ToInt32(comboBox1.Text);
字符串strText中=“”;
开关(intYear%12)
案例4:strText中=“鼠”; 打破;
情况5:strText中=“牛”; 打破;
案例6:strText中=“虎”; 打破;
案例7:strText中=“兔”; 打破;
案例8:strText中=“龙”; 打破;
案例9:strText中=“蛇”; 打破;
案例10:strText中=“马”; 打破;
案例11:strText中=“羊”; 打破;
情况下0:strText中=“猴”; 打破;
案例1:strText中=“鸡”; 打破;
案例2:strText中=“狗”; 打破;
案例3:strText中=“猪”; 打破;
的foreach(单选RBTN在groupBox1.Controls)
如果(rbtn.Text == strText中)
rbtn.Checked = TRUE;
Form1的设计:
命名空间RadioButton_1
部分Form1类
/ / /公升; summarygt
/ / /必需的设计器变量。
/ / / </摘要>
私人System.ComponentModel.IContainer成分= NULL;
/ / /公升; summarygt
/ / /清理所有正在使用的资源。
/ / / </摘要>
/ / / <param name="disposing">如果应释放托管资源,为真;否则为假</参数>
保护覆盖无效的Dispose(BOOL处置)
如果(处置&&(组件!= NULL))
components.Dispose();
base.Dispose(处置);
#地区的Windows窗体设计器生成的代码
/ / /公升; summarygt
/ / /设计器支持所需的方法 - 不要
/ / /使用代码编辑器修改此方法的内容。
/ / / </摘要>
私人无效的InitializeComponent()
this.label1 =新System.Windows.Forms.Label();
this.comboBox1 =新System.Windows.Forms.ComboBox();
this.groupBox1 =新System.Windows.Forms.GroupBox();
this.radioButton1 =新System.Windows.Forms.RadioButton();
this.radioButton2 =新System.Windows.Forms.RadioButton();
this.radioButton3 =新System.Windows.Forms.RadioButton();
this.radioButton4 =新System.Windows.Forms.RadioButton();
this.radioButton5 =新System.Windows.Forms.RadioButton();
this.radioButton6 =新System.Windows.Forms.RadioButton();
this.radioButton7 =新System.Windows.Forms.RadioButton();
this.radioButton8 =新System.Windows.Forms.RadioButton();
this.radioButton9 =新System.Windows.Forms.RadioButton();
this.radioButton10 =新System.Windows.Forms.RadioButton();
this.radioButton11 =新System.Windows.Forms.RadioButton();
this.radioButton12 =新System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
/ /
/ / LABEL1
/ /
this.label1.AutoSize = TRUE;
this.label1.Location =新System.Drawing.Point(28,32);
this.label1.Name =“label1的”;
this.label1.Size =新System.Drawing.Size(95,12);
this.label1.TabIndex = 0;
this.label1.Text =“请选择出生年份:”;
/ /
/ / comboBox1中
/ /
this.comboBox1.FormattingEnabled = TRUE;
this.comboBox1.Location =新System.Drawing.Point(130,32);
this.comboBox1.Name =“comboBox1中”;
this.comboBox1.Size =新System.Drawing.Size(121,20);
this.comboBox1.TabIndex = 1;
this.comboBox1.SelectedIndexChanged + =新System.EventHandler(this.comboBox1_SelectedIndexChanged);
/ /
/ / groupBox1
/ /
this.groupBox1.Controls.Add(this.radioButton11);
this.groupBox1.Controls.Add(this.radioButton10);
this.groupBox1.Controls.Add(this.radioButton9);
this.groupBox1.Controls.Add(this.radioButton8);
this.groupBox1.Controls.Add(this.radioButton7);
this.groupBox1.Controls.Add(this.radioButton6);
this.groupBox1.Controls.Add(this.radioButton5);
this.groupBox1.Controls.Add(this.radioButton4);
this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location =新System.Drawing.Point(30,68);
this.groupBox1.Name =“groupBox1”;
this.groupBox1.Size =新System.Drawing.Size(280,136);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = FALSE;
this.groupBox1.Text =“生肖”;
/ /
/ / radioButton1
/ /
this.radioButton1.AutoSize = TRUE;
this.radioButton1.Location =新System.Drawing.Point(6,20);
this.radioButton1.Name =“radioButton1”;
this.radioButton1.Size =新System.Drawing.Size(35,16);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = TRUE;
this.radioButton1.Text =“鼠”;
this.radioButton1.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton2
/ /
this.radioButton2.AutoSize = TRUE;
this.radioButton2.Location =新System.Drawing.Point(75,20);
this.radioButton2.Name =“radioButton2”;
this.radioButton2.Size =新System.Drawing.Size(35,16);
this.radioButton2.TabIndex = 1;
this.radioButton2.TabStop = TRUE;
this.radioButton2.Text =“牛”;
this.radioButton2.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton3
/ /
this.radioButton3.AutoSize = TRUE;
this.radioButton3.Location =新System.Drawing.Point(135,20);
this.radioButton3.Name =“radioButton3”;
this.radioButton3.Size =新System.Drawing.Size(35,16);
this.radioButton3.TabIndex = 2;
this.radioButton3.TabStop = TRUE;
this.radioButton3.Text =“虎”;
this.radioButton3.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton4
/ /
this.radioButton4.AutoSize = TRUE;
this.radioButton4.Location =新System.Drawing.Point(198,20);
this.radioButton4.Name =“radioButton4”;
this.radioButton4.Size =新System.Drawing.Size(35,16);
this.radioButton4.TabIndex = 3;
this.radioButton4.TabStop = TRUE;
this.radioButton4.Text =“兔”;
this.radioButton4.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton5
/ /
this.radioButton5.AutoSize = TRUE;
this.radioButton5.Location =新System.Drawing.Point(6,63);
this.radioButton5.Name =“radioButton5”;
this.radioButton5.Size =新System.Drawing.Size(35,16);
this.radioButton5.TabIndex = 4;
this.radioButton5.TabStop = TRUE;
this.radioButton5.Text =“龙”;
this.radioButton5.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton6
/ /
this.radioButton6.AutoSize = TRUE;
this.radioButton6.Location =新System.Drawing.Point(75,63);
this.radioButton6.Name =“radioButton6”;
this.radioButton6.Size =新System.Drawing.Size(35,16);
this.radioButton6.TabIndex = 5;
this.radioButton6.TabStop = TRUE;
this.radioButton6.Text =“蛇”;
this.radioButton6.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton7
/ /
this.radioButton7.AutoSize = TRUE;
this.radioButton7.Location =新System.Drawing.Point(135,63);
this.radioButton7.Name =“radioButton7”;
this.radioButton7.Size =新System.Drawing.Size(35,16);
this.radioButton7.TabIndex = 6;
this.radioButton7.TabStop = TRUE;
this.radioButton7.Text =“马”;
this.radioButton7.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton8
/ /
this.radioButton8.AutoSize = TRUE;
this.radioButton8.Location =新System.Drawing.Point(198,63);
this.radioButton8.Name =“radioButton8”;
this.radioButton8.Size =新System.Drawing.Size(35,16);
this.radioButton8.TabIndex = 7;
this.radioButton8.TabStop = TRUE;
this.radioButton8.Text =“羊”;
this.radioButton8.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton9
/ /
this.radioButton9.AutoSize = TRUE;
this.radioButton9.Location =新System.Drawing.Point(6,100);
this.radioButton9.Name =“radioButton9”;
this.radioButton9.Size =新System.Drawing.Size(35,16);
this.radioButton9.TabIndex = 8;
this.radioButton9.TabStop = TRUE;
this.radioButton9.Text =“猴”;
this.radioButton9.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton10
/ /
this.radioButton10.AutoSize = TRUE;
this.radioButton10.Location =新System.Drawing.Point(75,100);
this.radioButton10.Name =“radioButton10”;
this.radioButton10.Size =新System.Drawing.Size(35,16);
this.radioButton10.TabIndex = 9;
this.radioButton10.TabStop = TRUE;
this.radioButton10.Text =“鸡”;
this.radioButton10.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton11
/ /
this.radioButton11.AutoSize = TRUE;
this.radioButton11.Location =新System.Drawing.Point(135,100);
this.radioButton11.Name =“radioButton11”;
this.radioButton11.Size =新System.Drawing.Size(35,16);
this.radioButton11.TabIndex = 10;
this.radioButton11.TabStop = TRUE;
this.radioButton11.Text =“狗”;
this.radioButton11.UseVisualStyleBackColor = TRUE;
/ /
/ / radioButton12
/ /
this.radioButton12.AutoSize = TRUE;
this.radioButton12.Location =新System.Drawing.Point(228,168);
this.radioButton12.Name =“radioButton12”;
this.radioButton12.Size =新System.Drawing.Size(35,16);
this.radioButton12.TabIndex = 11;
this.radioButton12.TabStop = TRUE;
this.radioButton12.Text =“猪”;
this.radioButton12.UseVisualStyleBackColor = TRUE;
/ /
/ / Form1中
/ /
this.AutoScaleDimensions =新System.Drawing.SizeF(6F,12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize =新System.Drawing.Size(335,216);
this.Controls.Add(this.radioButton12);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Name =“Form1的”;
this.Text =“生肖查询”;
this.Load + =新System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(假);
this.groupBox1.PerformLayout();
this.ResumeLayout(假);
this.PerformLayout();
#endregion
私人System.Windows.Forms.Label LABEL1;
私人System.Windows.Forms.ComboBox comboBox1中;
私人System.Windows.Forms.GroupBox groupBox1;
私人System.Windows.Forms.RadioButton radioButton11;
私人System.Windows.Forms.RadioButton radioButton10;
私人System.Windows.Forms.RadioButton radioButton9;
私人System.Windows.Forms.RadioButton radioButton8;
私人System.Windows.Forms.RadioButton radioButton7;
私人System.Windows.Forms.RadioButton radioButton6;
私人System.Windows.Forms.RadioButton radioButton5;
私人System.Windows.Forms.RadioButton radioButton4;
私人System.Windows.Forms.RadioButton radioButton3;
私人System.Windows.Forms.RadioButton radioButton2;
私人System.Windows.Forms.RadioButton radioButton1;
私人System.Windows.Forms.RadioButton radioButton12;
以上是关于C#-RadioButton,comboBox,生肖查询---ShinePans的主要内容,如果未能解决你的问题,请参考以下文章
Button,CheckBox,Lable,RadioButton,ComboBox,TextBox六个简单控件的使用
python Python,Tkinter:Label,Button,Entry,Combobox,Checkbutton,Radiobutton,ScrolledText