2 Form 3 Yes Dialog Result Dialog Result

  • Slides: 17
Download presentation

Модальные диалоги -2 В примере модальный диалог (Form 3) закрывается при нажатии кнопки <Yes>,

Модальные диалоги -2 В примере модальный диалог (Form 3) закрывается при нажатии кнопки <Yes>, т. к. свойству Dialog. Result кнопки при инициализации присвоено значение перечисления Dialog. Result, и при нажатии кнопки <No>, так как в обработчике для кнопки <No> свойству Dialog. Result формы присваивается значение перечисления Dialog. Result. public class Form 3 : System. Windows. Form { private System. Windows. Forms. Button button 1; private System. Windows. Forms. Button button 2; private void Initialize. Component() { […code…] // button 1 this. button 1. Dialog. Result = System. Windows. Forms. Dialog. Result. Yes; this. button 1. Name = "button 1"; this. button 1. Text = "Yes"; […code…] // button 2 this. button 2. Name = "button 2"; this. button 2. Text = "No"; this. button 2. Click += new System. Event. Handler(this. button 2_Click); […code…] } private void button 2_Click(object sender, System. Event. Args e) {this. Dialog. Result = Dialog. Result. No; }

Немодальные диалоги. Пример ü Пример Modeless. Dialog. Класс Form 1 для основной формы public

Немодальные диалоги. Пример ü Пример Modeless. Dialog. Класс Form 1 для основной формы public class Form 1 : System. Windows. Form { private System. Windows. Forms. Button button_dialog; private System. Windows. Forms. Text. Box text. Box 1; Form 2 dlg ; public string Text. In. Form 1 { get { return text. Box 1. Text; } set { text. Box 1. Text = value; } } public bool Enable. Dialog. Button { get { return button_dialog. Enabled; } set { button_dialog. Enabled = value; } } [… code…] }

Немодальные диалоги. Пример -2 ü Обработчик события в Form 1, в котором создается немодальный

Немодальные диалоги. Пример -2 ü Обработчик события в Form 1, в котором создается немодальный диалог: public class Form 1 : System. Windows. Form { […code…] private void button_dialog_Click(object sender, System. Event. Args e) { button_dialog. Enabled = false; dlg = new Form 2(); dlg. Owner = this; dlg. Start. Position = Form. Start. Position. Manual; dlg. Location = new Point( this. Right-this. Right/5, this. Bottom-this. Bottom/5); dlg. Show(); Message. Box. Show("After dlg. Show(); "); } }

Немодальные диалоги. Пример -3 ü Пример Modeless. Dialog. Класс Form 2 для диалога: public

Немодальные диалоги. Пример -3 ü Пример Modeless. Dialog. Класс Form 2 для диалога: public class Form 2 : System. Windows. Form { [… code…] private System. Windows. Forms. Button button_apply; private System. Windows. Forms. Text. Box text. Box 1; private void button_apply_Click( object sender, System. Event. Args e) { ((Form 1)this. Owner). Text. In. Form 1 = this. text. Box 1. Text; } private void Form 2_Closed(object sender, System. Event. Args e) { ((Form 1)this. Owner). Enable. Dialog. Button = true; } }

Стандартные диалоги (Common dialog boxes) System. Object System. Marshal. By. Ref. Object System. Component.

Стандартные диалоги (Common dialog boxes) System. Object System. Marshal. By. Ref. Object System. Component. Model. Component System. Windows. Forms. Common. Dialog System. Windows. Forms. Color. Dialog System. Windows. Forms. File. Dialog System. Windows. Forms. Open. File. Dialog System. Windows. Forms. Save. File. Dialog System. Windows. Forms. Folder. Browser. Dialog System. Windows. Forms. Font. Dialog System. Windows. Forms. Page. Setup. Dialog System. Windows. Forms. Print. Dialog

Класс Tab. Page ü Класс Tab. Page описывает отдельную страницу диалога Tab. Control: System.

Класс Tab. Page ü Класс Tab. Page описывает отдельную страницу диалога Tab. Control: System. Object System. Marshal. By. Ref. Object System. Component. Model. Component System. Windows. Forms. Control System. Windows. Forms. Scrollable. Control System. Windows. Forms. Panel System. Windows. Forms. Tab. Page ü Класс Tab. Page является производным от класса Control и наследует все его свойства и методы. ü Открытые свойства класса Tab. Page: public int Image. Index {get; set; } Индекс изображения, который выводится на закладку для страницы. override string Text {get; set; } Текст на закладке страницы. string Tool. Tip. Text {get; set; } Текст подсказки для страницы.