RadioButton Image : RadioButton « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » RadioButton 
23.11.5.RadioButton Image
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : 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;

    public Form1() {
        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();
        this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.radioButton3,
this.radioButton2,
this.radioButton1});
        this.groupBox1.Location = new System.Drawing.Point(816);
        this.groupBox1.Size = new System.Drawing.Size(160120);
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "Group 1";
        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(1688);
        this.radioButton3.Name = "radioButton3";
        this.radioButton3.Size = new System.Drawing.Size(12024);
        this.radioButton3.TabIndex = 2;
        this.radioButton3.Text = "Option3";

        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(1656);
        this.radioButton2.Size = new System.Drawing.Size(12024);
        this.radioButton2.Text = "Option2";
        this.radioButton2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
        this.radioButton1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255))((System.Byte)(192))((System.Byte)(192)));
        this.radioButton1.Location = new System.Drawing.Point(1624);
        this.radioButton1.Size = new System.Drawing.Size(12024);
        this.radioButton1.Text = "Option1";
        this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
        this.AutoScaleBaseSize = new System.Drawing.Size(513);
        this.ClientSize = new System.Drawing.Size(184149);
        this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox1});
        this.Text = "Radio Button";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.groupBox1.ResumeLayout(false);
        this.ResumeLayout(false);
    }
    [STAThread]
    static void Main() {
        Application.Run(new Form1());
    }

    private void Form1_Load(object sender, System.EventArgs e) {
        Image img = Image.FromFile("EYE.ICO");
        radioButton1.Image = img;
        radioButton1.ImageAlign = ContentAlignment.MiddleRight;
        img = Image.FromFile("WRENCH.ICO");
        radioButton2.Image = img;
        radioButton2.ImageAlign = ContentAlignment.MiddleLeft;
    }

    private void radioButton1_CheckedChanged(object sender, System.EventArgs e) {
        if (radioButton1.Checked)
            MessageBox.Show("Checked!");
        else
            MessageBox.Show("Not checked!");
    }
}
23.11.RadioButton
23.11.1.RadioButton Click EventRadioButton Click Event
23.11.2.Put RadioButton to panel groupPut RadioButton to panel group
23.11.3.Set DialogResult.OK/DialogResult.Cancel to OK/Cancel buttonSet DialogResult.OK/DialogResult.Cancel to OK/Cancel button
23.11.4.Use RadioButton to control ListBox selection modeUse RadioButton to control ListBox selection mode
23.11.5.RadioButton Image
23.11.6.Color Radio Buttons
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.