Windows forms form shown

Form. Show Dialog Метод

Определение

Отображает форму как модальное диалоговое окно. Shows the form as a modal dialog box.

Перегрузки

Отображает форму как модальное диалоговое окно. Shows the form as a modal dialog box.

Отображает эту форму в виде модального диалогового окна с указанным владельцем. Shows the form as a modal dialog box with the specified owner.

ShowDialog()

Отображает форму как модальное диалоговое окно. Shows the form as a modal dialog box.

Возвращаемое значение

Одно из значений перечисления DialogResult. One of the DialogResult values.

Исключения

Отображаемая форма уже отображена. The form being shown is already visible.

-или- -or- Отображаемая форма отключена. The form being shown is disabled.

-или- -or- Отображаемая форма не является окном верхнего уровня. The form being shown is not a top-level window.

-или- -or- Отображаемая в виде диалогового окна форма уже является модальной формой. The form being shown as a dialog box is already a modal form.

-или- -or- Текущий процесс не выполняется в интерактивном пользовательском режиме (дополнительные сведения см. в описании свойства UserInteractive). The current process is not running in user interactive mode (for more information, see UserInteractive).

Примеры

В следующем примере форма отображается как модальное диалоговое окно и вычисляет возвращаемое значение диалогового окна перед тем, как определить, следует ли считать значение TextBox элемента управления в форме диалогового окна. The following example displays a form as a modal dialog box and evaluates the return value of the dialog box before determining whether to read the value of a TextBox control on the dialog box form. В этом примере необходимо Form создать именованный объект, testDialog содержащий TextBox элемент управления с именем TextBox1 . This example requires that a Form named testDialog is created and that it contains a TextBox control named TextBox1 . Кроме того, в примере требуется, чтобы код в этом примере содержал и вызывался из другого Form списка, чтобы его можно было отобразить testDialog как модальное диалоговое окно. Furthermore, the example requires that code in this example is contained and called from a different Form in order to display testDialog as a modal dialog box. В примере используется версия ShowDialog , которая задает владельца для диалогового окна. The example uses the version of ShowDialog that specifies an owner for the dialog box.

Комментарии

Этот метод можно использовать для вывода модального диалогового окна в приложении. You can use this method to display a modal dialog box in your application. При вызове этого метода код, следующий за ним, не выполняется до тех пор, пока не будет закрыто диалоговое окно. When this method is called, the code following it is not executed until after the dialog box is closed. Диалоговому окну можно назначить одно из значений DialogResult перечисления, назначив его DialogResult свойству объекта Button в форме или задав DialogResult свойство формы в коде. The dialog box can be assigned one of the values of the DialogResult enumeration by assigning it to the DialogResult property of a Button on the form or by setting the DialogResult property of the form in code. Это значение затем возвращается этим методом. This value is then returned by this method. Это возвращаемое значение можно использовать для определения способа обработки действий, произошедших в диалоговом окне. You can use this return value to determine how to process the actions that occurred in the dialog box. Например, если диалоговое окно было закрыто и возвращено DialogResult.Cancel значение с помощью этого метода, можно предотвратить исполнение кода, следующего за вызовом ShowDialog . For example, if the dialog box was closed and returned the DialogResult.Cancel value through this method, you could prevent code following the call to ShowDialog from executing.

Читайте также:  Uninstall driver linux mint

Когда форма отображается как модальное диалоговое окно, нажатие кнопки Закрыть (кнопка с крестиком в правом верхнем углу формы) приводит к скрытию формы и свойству, для которого DialogResult устанавливается значение DialogResult.Cancel . When a form is displayed as a modal dialog box, clicking the Close button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the DialogResult property to be set to DialogResult.Cancel . В отличие от немодальных форм, Close метод не вызывается платформа .NET Framework, когда пользователь нажимает кнопку «Закрыть форму» диалогового окна или задает значение DialogResult Свойства. Unlike non-modal forms, the Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the DialogResult property. Вместо этого форма скрыта, и ее можно снова отобразить, не создавая новый экземпляр диалогового окна. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Так как форма, отображаемая как диалоговое окно, скрыта, а не закрыта, необходимо вызвать Dispose метод формы, если форма больше не нужна приложению. Because a form displayed as a dialog box is hidden instead of closed, you must call the Dispose method of the form when the form is no longer needed by your application.

Эта версия ShowDialog метода не указывает форму или элемент управления как владельца. This version of the ShowDialog method does not specify a form or control as its owner. При вызове этой версии текущее активное окно становится владельцем диалогового окна. When this version is called, the currently active window is made the owner of the dialog box. Если вы хотите указать конкретного владельца, используйте другую версию этого метода. If you want to specify a specific owner, use the other version of this method.

Form2.show()

Show() и showdialog()
У меня созданы 2 формы. При нажатии на кнопку на первой форме открывается вторая (методом Show()) и.

MessageBox.Show()
Здравствуйте! Я вызываю метод MessageBox.Show(«. «) и мне необходимо, что бы пока я его не.

Из Form2 в Form1
В form1, после нажатия на кнопку открывается form2. Там можно выбрать и просмотреть картинки. Так.

form2 главная
Как можно сделать form2 главной?

Form FormName = new Form2();
FormName.Show();

Тематические курсы и обучение профессиям онлайн
Профессия‌ С#-разработчик‌ (Skillbox)
Архитектор ПО (Skillbox)
Профессия Тестировщик (Skillbox)

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Из form1 в form2
Запарился уже искать то что нужно! В общем при нажатии на форм 1 считываются координаты и в.

Form.Show() в потоке
Необходимо вызвать метод Show в потоке. Когда форма появляется на экране она зависает пока цикл не.

Не выходит MessageBox.Show
Приветствую, перепробовал множество вариантов но при нажатие на кнопку так и не выходит. Не понимаю.

Создание Form2 и её контролов
Здравствуйте! Решил поэкспериментировать и что-то получается не то! Итак есть from1, на которой.

Form. Show(IWin32Window) Метод

Определение

Показывает форму с указанным владельцем. Shows the form with the specified owner to the user.

Читайте также:  Как посмотреть лицензионный windows или нет

Параметры

Любой объект, который реализует IWin32Window, представляющий окно верхнего уровня, которое станет владельцем этой формы. Any object that implements IWin32Window and represents the top-level window that will own this form.

Исключения

Отображаемая форма уже отображена. The form being shown is already visible.

-или- -or- Форма, указанная в параметре owner , совпадает с отображаемой формой. The form specified in the owner parameter is the same as the form being shown.

-или- -or- Отображаемая форма отключена. The form being shown is disabled.

-или- -or- Отображаемая форма не является окном верхнего уровня. The form being shown is not a top-level window.

-или- -or- Отображаемая в виде диалогового окна форма уже является модальной формой. The form being shown as a dialog box is already a modal form.

-или- -or- Текущий процесс не выполняется в интерактивном пользовательском режиме (дополнительные сведения см. в описании свойства UserInteractive). The current process is not running in user interactive mode (for more information, see UserInteractive).

Комментарии

Этот метод можно использовать для вывода не модальной формы. You can use this method to display a non-modal form. При использовании этого метода Owner свойство формы устанавливается в значение owner . When you use this method, the Owner property of the form is set to owner . Немодальная форма может использовать Owner свойство для получения сведений о форме-владельце. The non-modal form can use the Owner property to get information about the owning form. Вызов этого метода идентичен заданию Owner Свойства немодального объекта и последующему вызову Show() метода. Calling this method is identical to setting the Owner property of the non-modal and then calling the Show() method.

Отображение формы эквивалентно присвоению Visible свойству значения true . Showing the form is equivalent to setting the Visible property to true . После Show вызова метода Visible свойство возвращает значение true до тех пор, пока Hide не будет вызван метод. After the Show method is called, the Visible property returns a value of true until the Hide method is called.

Form. Shown Событие

Определение

Происходит при первом отображении формы. Occurs whenever the form is first displayed.

Тип события

Примеры

В следующем примере демонстрируется использование этого элемента. The following example demonstrates the use of this member. В этом примере обработчик событий сообщает о возникновении Shown события. In the example, an event handler reports on the occurrence of the Shown event. Этот отчет поможет вам узнать, когда происходит событие и может помочь при отладке. This report helps you to learn when the event occurs and can assist you in debugging. Чтобы сообщить о нескольких событиях или о событиях, которые происходят часто, рассмотрите возможность замены MessageBox.Show Console.WriteLine или добавления сообщения в многострочный TextBox . To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

Чтобы выполнить пример кода, вставьте его в проект, содержащий экземпляр типа Form с именем Form1 . To run the example code, paste it into a project that contains an instance of type Form named Form1 . Затем убедитесь, что обработчик событий связан с Shown событием. Then ensure that the event handler is associated with the Shown event.

Комментарии

ShownСобытие вызывается только при первом отображении формы; последующее свертывание, увеличение, восстановление, скрытие, отображение или невозможность, а также перерисовку не вызовет этого события. The Shown event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting will not raise this event. Дополнительные сведения о порядке событий формы см. в разделе Порядок событий в Windows Forms. For more information about the order of events of a form, see Order of Events in Windows Forms.

Читайте также:  Кто может победить линукс

Дополнительные сведения об обработке событий см. в разделе обработка и вызов событий. For more information about handling events, see Handling and Raising Events.

Form. Show Dialog Method

Definition

Shows the form as a modal dialog box.

Overloads

Shows the form as a modal dialog box.

Shows the form as a modal dialog box with the specified owner.

ShowDialog()

Shows the form as a modal dialog box.

Returns

One of the DialogResult values.

Exceptions

The form being shown is already visible.

The form being shown is disabled.

The form being shown is not a top-level window.

The form being shown as a dialog box is already a modal form.

The current process is not running in user interactive mode (for more information, see UserInteractive).

Examples

The following example displays a form as a modal dialog box and evaluates the return value of the dialog box before determining whether to read the value of a TextBox control on the dialog box form. This example requires that a Form named testDialog is created and that it contains a TextBox control named TextBox1 . Furthermore, the example requires that code in this example is contained and called from a different Form in order to display testDialog as a modal dialog box. The example uses the version of ShowDialog that specifies an owner for the dialog box.

Remarks

You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed. The dialog box can be assigned one of the values of the DialogResult enumeration by assigning it to the DialogResult property of a Button on the form or by setting the DialogResult property of the form in code. This value is then returned by this method. You can use this return value to determine how to process the actions that occurred in the dialog box. For example, if the dialog box was closed and returned the DialogResult.Cancel value through this method, you could prevent code following the call to ShowDialog from executing.

When a form is displayed as a modal dialog box, clicking the Close button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the DialogResult property to be set to DialogResult.Cancel . Unlike non-modal forms, the Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the DialogResult property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is hidden instead of closed, you must call the Dispose method of the form when the form is no longer needed by your application.

This version of the ShowDialog method does not specify a form or control as its owner. When this version is called, the currently active window is made the owner of the dialog box. If you want to specify a specific owner, use the other version of this method.

Оцените статью