русс | укр

C# - Главная
Контакты
Задайте вопрос...
Просмотр всех вопросов


Пространство имен
  ► System
  ► Microsoft


Для учеников (начинающих)
  ► Видео уроки
  ► Обучение
  ► Примеры программ
  ► Секреты в Си Шарп

Для профессионалов
  ► Обучение
  ► Примеры программ
  ► Задачки - для тебя!










Пример размещения компонентов в приложении C#

На рисунке 16 представлено окно приложения, которое демонстрирует рассмотренные выше компоненты в действии.

 

 

Рисунок 16 – Пример

При размещении этих компонентов Visual Studio автоматически создала код для каждого компонента, который можно просмотреть, выбрав вкладку Form.Designer.cs, где расположен исходный текст данного приложения.

Окно Form1.Designer.cs показано на рисунке 17.

 

 

Рисунок 17 – Пример

 

Далее приведен код, который был сгенерирован для данного приложения:

 

#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.button1 = new System.Windows.Forms.Button();

this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();

this.label1 = new System.Windows.Forms.Label();

this.listBox1 = new System.Windows.Forms.ListBox();

this.label4 = new System.Windows.Forms.Label();

this.radioButton1 = new System.Windows.Forms.RadioButton();

this.radioButton2 = new System.Windows.Forms.RadioButton();

this.radioButton3 = new System.Windows.Forms.RadioButton();

this.radioButton4 = new System.Windows.Forms.RadioButton();

this.label5 = new System.Windows.Forms.Label();

this.button2 = new System.Windows.Forms.Button();

this.textBox1 = new System.Windows.Forms.TextBox();

this.label2 = new System.Windows.Forms.Label();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(12, 342);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "ОК";

this.button1.UseVisualStyleBackColor = true;

//

// checkedListBox1

//

this.checkedListBox1.FormattingEnabled = true;

this.checkedListBox1.Items.AddRange(new object[] {

"ComboBox",

"TextBox",

"ProgressBar",

"RichTextBox"});

this.checkedListBox1.Location = new System.Drawing.Point(15, 25);

this.checkedListBox1.Name = "checkedListBox1";

this.checkedListBox1.Size = new System.Drawing.Size(181, 64);

this.checkedListBox1.TabIndex = 2;

//

// label1

//

this.label1.AutoSize = true;

this.label1.Location = new System.Drawing.Point(12, 9);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(349, 13);

this.label1.TabIndex = 3;

this.label1.Text = "Какой элемент лучше использовать для большого объема текста?";

this.label1.Click += new System.EventHandler(this.label1_Click);

//

// listBox1

//

this.listBox1.FormattingEnabled = true;

this.listBox1.Items.AddRange(new object[] {

"LinkLabel",

"RadioButton",

"Label",

"TextBox"});

this.listBox1.Location = new System.Drawing.Point(12, 237);

this.listBox1.Name = "listBox1";

this.listBox1.Size = new System.Drawing.Size(175, 56);

this.listBox1.TabIndex = 6;

//

// label4

//

this.label4.AutoSize = true;

this.label4.Location = new System.Drawing.Point(12, 107);

this.label4.Name = "label4";

this.label4.Size = new System.Drawing.Size(337, 13);

this.label4.TabIndex = 12;

this.label4.Text = "Какой элемент используется в качестве индикатора процесса? ";

//

// radioButton1

//

this.radioButton1.AutoSize = true;

this.radioButton1.Location = new System.Drawing.Point(15, 123);

this.radioButton1.Name = "radioButton1";

this.radioButton1.Size = new System.Drawing.Size(51, 17);

this.radioButton1.TabIndex = 13;

this.radioButton1.TabStop = true;

this.radioButton1.Text = "Label";

this.radioButton1.UseVisualStyleBackColor = true;

//

// radioButton2

//

this.radioButton2.AutoSize = true;

this.radioButton2.Location = new System.Drawing.Point(15, 146);

this.radioButton2.Name = "radioButton2";

this.radioButton2.Size = new System.Drawing.Size(71, 17);

this.radioButton2.TabIndex = 14;

this.radioButton2.TabStop = true;

this.radioButton2.Text = "LinkLabel";

this.radioButton2.UseVisualStyleBackColor = true;

//

// radioButton3

//

this.radioButton3.AutoSize = true;

this.radioButton3.Location = new System.Drawing.Point(15, 169);

this.radioButton3.Name = "radioButton3";

this.radioButton3.Size = new System.Drawing.Size(56, 17);

this.radioButton3.TabIndex = 15;

this.radioButton3.TabStop = true;

this.radioButton3.Text = "Button";

this.radioButton3.UseVisualStyleBackColor = true;

//

// radioButton4

//

this.radioButton4.AutoSize = true;

this.radioButton4.Location = new System.Drawing.Point(15, 192);

this.radioButton4.Name = "radioButton4";

this.radioButton4.Size = new System.Drawing.Size(82, 17);

this.radioButton4.TabIndex = 16;

this.radioButton4.TabStop = true;

this.radioButton4.Text = "ProgressBar";

this.radioButton4.UseVisualStyleBackColor = true;

//

// label5

//

this.label5.AutoSize = true;

this.label5.Location = new System.Drawing.Point(12, 221);

this.label5.Name = "label5";

this.label5.Size = new System.Drawing.Size(396, 13);

this.label5.TabIndex = 17;

this.label5.Text = "Какой элемент используется для отображения гиперссылки для Интернет?";

//

// button2

//

this.button2.Location = new System.Drawing.Point(93, 342);

this.button2.Name = "button2";

this.button2.Size = new System.Drawing.Size(75, 23);

this.button2.TabIndex = 1;

this.button2.Text = "Cancel";

this.button2.UseVisualStyleBackColor = true;

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(109, 308);

this.textBox1.Name = "textBox1";

this.textBox1.Size = new System.Drawing.Size(100, 20);

this.textBox1.TabIndex = 4;

//

// label2

//

this.label2.AutoSize = true;

this.label2.Location = new System.Drawing.Point(12, 308);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(91, 13);

this.label2.TabIndex = 8;

this.label2.Text = "Введи свое имя:";

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(486, 377);

this.Controls.Add(this.label5);

this.Controls.Add(this.radioButton4);

this.Controls.Add(this.radioButton3);

this.Controls.Add(this.radioButton2);

this.Controls.Add(this.radioButton1);

this.Controls.Add(this.label4);

this.Controls.Add(this.label2);

this.Controls.Add(this.listBox1);

this.Controls.Add(this.textBox1);

this.Controls.Add(this.label1);

this.Controls.Add(this.checkedListBox1);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Name = "Form1";

this.Text = "Тест";

this.ResumeLayout(false);

this.PerformLayout();

 

}

 

#endregion

 


Просмотров: 5802






© 2012 ci-sharp.ru При использовании материала прямая индексирующая ссылка на сайт ОБЯЗАТЕЛЬНА.
Права строго защищены нормами международного права, интеллектуальной собственности и авторского права.