Add controls to Tab page : Tab « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » TabScreenshots 
Add controls to Tab page
Add controls to Tab page

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
{
      private System.Windows.Forms.TabControl textOptionsTabControl;
      private System.Windows.Forms.TabPage colorTabPage;
      private System.Windows.Forms.TabPage sizeTabPage;
      private System.Windows.Forms.TabPage messageTabPage;
      private System.Windows.Forms.TabPage aboutTabPage;
      private System.Windows.Forms.RadioButton greenRadioButton;
      private System.Windows.Forms.RadioButton redRadioButton;
      private System.Windows.Forms.RadioButton blackRadioButton;
      private System.Windows.Forms.RadioButton size20RadioButton;
      private System.Windows.Forms.RadioButton size16RadioButton;
      private System.Windows.Forms.RadioButton size12RadioButton;
      private System.Windows.Forms.RadioButton helloRadioButton;
      private System.Windows.Forms.RadioButton goodbyeRadioButton;
      private System.Windows.Forms.Label messageLabel;
      private System.Windows.Forms.Label displayLabel;
      
    public Form1() {
        InitializeComponent();
    }
      private void blackRadioButton_CheckedChanged(object sender, EventArgs e )
      {
         displayLabel.ForeColor = Color.Black;
      }

      private void redRadioButton_CheckedChanged(object sender, EventArgs e )
      {
         displayLabel.ForeColor = Color.Red;
      

      private void greenRadioButton_CheckedChanged(object sender, EventArgs e ) {
         displayLabel.ForeColor = Color.Green; 
      }

      private void size12RadioButton_CheckedChanged(object sender, EventArgs e ) {
         displayLabel.Font = new FontdisplayLabel.Font.Name, 12 );
      }

      private void size16RadioButton_CheckedChanged(object sender, EventArgs e ) {
         displayLabel.Font = new FontdisplayLabel.Font.Name, 16 );
      }

      private void size20RadioButton_CheckedChanged(object sender, EventArgs e ){
         displayLabel.Font = new FontdisplayLabel.Font.Name, 20 );
      }

      private void helloRadioButton_CheckedChanged(object sender, EventArgs e ) {
         displayLabel.Text = "Hello!";
      }
      private void goodbyeRadioButton_CheckedChangedobject sender, EventArgs e ) {
         displayLabel.Text = "Goodbye!";
      }
      
      private void InitializeComponent()
      {
         this.textOptionsTabControl = new System.Windows.Forms.TabControl();
         this.colorTabPage = new System.Windows.Forms.TabPage();
         this.greenRadioButton = new System.Windows.Forms.RadioButton();
         this.redRadioButton = new System.Windows.Forms.RadioButton();
         this.blackRadioButton = new System.Windows.Forms.RadioButton();
         this.sizeTabPage = new System.Windows.Forms.TabPage();
         this.size20RadioButton = new System.Windows.Forms.RadioButton();
         this.size16RadioButton = new System.Windows.Forms.RadioButton();
         this.size12RadioButton = new System.Windows.Forms.RadioButton();
         this.messageTabPage = new System.Windows.Forms.TabPage();
         this.goodbyeRadioButton = new System.Windows.Forms.RadioButton();
         this.helloRadioButton = new System.Windows.Forms.RadioButton();
         this.aboutTabPage = new System.Windows.Forms.TabPage();
         this.messageLabel = new System.Windows.Forms.Label();
         this.displayLabel = new System.Windows.Forms.Label();
         this.textOptionsTabControl.SuspendLayout();
         this.colorTabPage.SuspendLayout();
         this.sizeTabPage.SuspendLayout();
         this.messageTabPage.SuspendLayout();
         this.aboutTabPage.SuspendLayout();
         this.SuspendLayout();
         // 
         // textOptionsTabControl
         // 
         this.textOptionsTabControl.Controls.Add(this.colorTabPage);
         this.textOptionsTabControl.Controls.Add(this.sizeTabPage);
         this.textOptionsTabControl.Controls.Add(this.messageTabPage);
         this.textOptionsTabControl.Controls.Add(this.aboutTabPage);
         this.textOptionsTabControl.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.textOptionsTabControl.Location = new System.Drawing.Point(1212);
         this.textOptionsTabControl.Name = "textOptionsTabControl";
         this.textOptionsTabControl.SelectedIndex = 0;
         this.textOptionsTabControl.Size = new System.Drawing.Size(315186);
         this.textOptionsTabControl.TabIndex = 0;
         // 
         // colorTabPage
         // 
         this.colorTabPage.Controls.Add(this.greenRadioButton);
         this.colorTabPage.Controls.Add(this.redRadioButton);
         this.colorTabPage.Controls.Add(this.blackRadioButton);
         this.colorTabPage.Location = new System.Drawing.Point(429);
         this.colorTabPage.Name = "colorTabPage";
         this.colorTabPage.Padding = new System.Windows.Forms.Padding(3);
         this.colorTabPage.Size = new System.Drawing.Size(307153);
         this.colorTabPage.TabIndex = 0;
         this.colorTabPage.Text = "Color";
         // 
         // greenRadioButton
         // 
         this.greenRadioButton.AutoSize = true;
         this.greenRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.greenRadioButton.Location = new System.Drawing.Point(34106);
         this.greenRadioButton.Name = "greenRadioButton";
         this.greenRadioButton.Size = new System.Drawing.Size(6724);
         this.greenRadioButton.TabIndex = 2;
         this.greenRadioButton.Text = "Green";
         this.greenRadioButton.CheckedChanged += new System.EventHandler(this.greenRadioButton_CheckedChanged);
         // 
         // redRadioButton
         // 
         this.redRadioButton.AutoSize = true;
         this.redRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.redRadioButton.Location = new System.Drawing.Point(3459);
         this.redRadioButton.Name = "redRadioButton";
         this.redRadioButton.Size = new System.Drawing.Size(5224);
         this.redRadioButton.TabIndex = 1;
         this.redRadioButton.Text = "Red";
         this.redRadioButton.CheckedChanged += new System.EventHandler(this.redRadioButton_CheckedChanged);
         // 
         // blackRadioButton
         // 
         this.blackRadioButton.AutoSize = true;
         this.blackRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.blackRadioButton.Location = new System.Drawing.Point(3415);
         this.blackRadioButton.Name = "blackRadioButton";
         this.blackRadioButton.Size = new System.Drawing.Size(6124);
         this.blackRadioButton.TabIndex = 0;
         this.blackRadioButton.Text = "Black";
         this.blackRadioButton.CheckedChanged += new System.EventHandler(this.blackRadioButton_CheckedChanged);
         // 
         // sizeTabPage
         // 
         this.sizeTabPage.Controls.Add(this.size20RadioButton);
         this.sizeTabPage.Controls.Add(this.size16RadioButton);
         this.sizeTabPage.Controls.Add(this.size12RadioButton);
         this.sizeTabPage.Location = new System.Drawing.Point(422);
         this.sizeTabPage.Name = "sizeTabPage";
         this.sizeTabPage.Padding = new System.Windows.Forms.Padding(3);
         this.sizeTabPage.Size = new System.Drawing.Size(307160);
         this.sizeTabPage.TabIndex = 1;
         this.sizeTabPage.Text = "Size";
         // 
         // size20RadioButton
         // 
         this.size20RadioButton.AutoSize = true;
         this.size20RadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.size20RadioButton.Location = new System.Drawing.Point(34106);
         this.size20RadioButton.Name = "size20RadioButton";
         this.size20RadioButton.Size = new System.Drawing.Size(7924);
         this.size20RadioButton.TabIndex = 2;
         this.size20RadioButton.Text = "20 point";
         this.size20RadioButton.CheckedChanged += new System.EventHandler(this.size20RadioButton_CheckedChanged);
         // 
         // size16RadioButton
         // 
         this.size16RadioButton.AutoSize = true;
         this.size16RadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.size16RadioButton.Location = new System.Drawing.Point(3459);
         this.size16RadioButton.Name = "size16RadioButton";
         this.size16RadioButton.Size = new System.Drawing.Size(7924);
         this.size16RadioButton.TabIndex = 1;
         this.size16RadioButton.Text = "16 point";
         this.size16RadioButton.CheckedChanged += new System.EventHandler(this.size16RadioButton_CheckedChanged);
         // 
         // size12RadioButton
         // 
         this.size12RadioButton.AutoSize = true;
         this.size12RadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.size12RadioButton.Location = new System.Drawing.Point(3415);
         this.size12RadioButton.Name = "size12RadioButton";
         this.size12RadioButton.Size = new System.Drawing.Size(7924);
         this.size12RadioButton.TabIndex = 0;
         this.size12RadioButton.Text = "12 point";
         this.size12RadioButton.CheckedChanged += new System.EventHandler(this.size12RadioButton_CheckedChanged);
         // 
         // messageTabPage
         // 
         this.messageTabPage.Controls.Add(this.goodbyeRadioButton);
         this.messageTabPage.Controls.Add(this.helloRadioButton);
         this.messageTabPage.Location = new System.Drawing.Point(429);
         this.messageTabPage.Name = "messageTabPage";
         this.messageTabPage.Size = new System.Drawing.Size(307153);
         this.messageTabPage.TabIndex = 2;
         this.messageTabPage.Text = "Message";
         // 
         // goodbyeRadioButton
         // 
         this.goodbyeRadioButton.AutoSize = true;
         this.goodbyeRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.goodbyeRadioButton.Location = new System.Drawing.Point(2966);
         this.goodbyeRadioButton.Name = "goodbyeRadioButton";
         this.goodbyeRadioButton.Size = new System.Drawing.Size(9124);
         this.goodbyeRadioButton.TabIndex = 1;
         this.goodbyeRadioButton.Text = "Goodbye!";
         this.goodbyeRadioButton.CheckedChanged += new System.EventHandler(this.goodbyeRadioButton_CheckedChanged);
         // 
         // helloRadioButton
         // 
         this.helloRadioButton.AutoSize = true;
         this.helloRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.helloRadioButton.Location = new System.Drawing.Point(2921);
         this.helloRadioButton.Name = "helloRadioButton";
         this.helloRadioButton.Size = new System.Drawing.Size(6224);
         this.helloRadioButton.TabIndex = 0;
         this.helloRadioButton.Text = "Hello!";
         this.helloRadioButton.CheckedChanged += new System.EventHandler(this.helloRadioButton_CheckedChanged);
         // 
         // aboutTabPage
         // 
         this.aboutTabPage.Controls.Add(this.messageLabel);
         this.aboutTabPage.Location = new System.Drawing.Point(429);
         this.aboutTabPage.Name = "aboutTabPage";
         this.aboutTabPage.Size = new System.Drawing.Size(307153);
         this.aboutTabPage.TabIndex = 3;
         this.aboutTabPage.Text = "About";
         // 
         // messageLabel
         // 
         this.messageLabel.Font = new System.Drawing.Font("Microsoft Sans Serif"12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.messageLabel.Location = new System.Drawing.Point(1820);
         this.messageLabel.Name = "messageLabel";
         this.messageLabel.Size = new System.Drawing.Size(22799);
         this.messageLabel.TabIndex = 0;
         this.messageLabel.Text = "Info tab";
         // 
         // displayLabel
         // 
         this.displayLabel.Location = new System.Drawing.Point(120211);
         this.displayLabel.Name = "displayLabel";
         this.displayLabel.Text = "www.java2java.com";
         this.displayLabel.Size = new System.Drawing.Size(14642);
         this.displayLabel.TabIndex = 1;
         this.displayLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
         // 
         // UsingTabsForm
         // 
         this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
         this.ClientSize = new System.Drawing.Size(340262);
         this.Controls.Add(this.displayLabel);
         this.Controls.Add(this.textOptionsTabControl);
         this.Name = "UsingTabsForm";
         this.Text = "Using Tabs";
         this.textOptionsTabControl.ResumeLayout(false);
         this.colorTabPage.ResumeLayout(false);
         this.colorTabPage.PerformLayout();
         this.sizeTabPage.ResumeLayout(false);
         this.sizeTabPage.PerformLayout();
         this.messageTabPage.ResumeLayout(false);
         this.messageTabPage.PerformLayout();
         this.aboutTabPage.ResumeLayout(false);
         this.ResumeLayout(false);

      }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}



           
       
Related examples in the same category
1.TabControl
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.