本文整理汇总了C#中System.Windows.Forms.RadioButton.Appearance属性的典型用法代码示例。如果您正苦于以下问题:C# RadioButton.Appearance属性的具体用法?C# RadioButton.Appearance怎么用?C# RadioButton.Appearance使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.RadioButton
的用法示例。
在下文中一共展示了RadioButton.Appearance属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeMyRadioButton
private void InitializeMyRadioButton()
{
// Create and initialize a new RadioButton.
RadioButton radioButton1 = new RadioButton();
// Make the radio button control appear as a toggle button.
radioButton1.Appearance = Appearance.Button;
// Turn off the update of the display on the click of the control.
radioButton1.AutoCheck = false;
// Add the radio button to the form.
Controls.Add(radioButton1);
}
示例2: RadioButtonWithImg
/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury,
Zach Greenvoss, Shripad Kulkarni, Neil Whitlow
Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace RadioButtonWithImg
{
/// <summary>
/// Summary description for RadioButtonWithImg.
/// </summary>
public class RadioButtonWithImg : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public RadioButtonWithImg()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.radioButton3,
this.radioButton2,
this.radioButton1});
this.groupBox1.Location = new System.Drawing.Point(8, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(160, 120);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Group 1";
//
// radioButton3
//
this.radioButton3.Appearance = System.Windows.Forms.Appearance.Button;
this.radioButton3.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(255)));
this.radioButton3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioButton3.Location = new System.Drawing.Point(16, 88);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(120, 24);
this.radioButton3.TabIndex = 2;
this.radioButton3.Text = "Option3";
//
// radioButton2
//
this.radioButton2.Appearance = System.Windows.Forms.Appearance.Button;
this.radioButton2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.radioButton2.Location = new System.Drawing.Point(16, 56);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(120, 24);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "Option2";
this.radioButton2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// radioButton1
//
this.radioButton1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(192)));
this.radioButton1.Location = new System.Drawing.Point(16, 24);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(120, 24);
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "Option1";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// RadioButton
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(184, 149);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox1});
this.Name = "RadioButton";
this.Text = "Radio Button";
this.Load += new System.EventHandler(this.RadioButtonWithImg_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new RadioButtonWithImg());
}
private void RadioButtonWithImg_Load(object sender, System.EventArgs e)
{
// Select the Image for the button
Image img = Image.FromFile("EYE.ICO");
// Assign the Image to the button
radioButton1.Image = img ;
// Align the image
radioButton1.ImageAlign = ContentAlignment.MiddleRight;
// Select the Image for the button
img = Image.FromFile("WRENCH.ICO");
// Assign the Image to the button
radioButton2.Image = img ;
// Align the image
radioButton2.ImageAlign = ContentAlignment.MiddleLeft;
}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton1.Checked)
MessageBox.Show("Checked!");
else
MessageBox.Show("Not checked!");
}
}
}