How to: Retrieve Data from a Dialog Box


 

Dialog boxes enable your program to interact with users and retrieve data that users have entered in the dialog box for use in your application. There are several built-in dialog boxes that you can use in your applications. You can also create your own dialog boxes.

A common task in Windows Forms development is displaying a dialog box to collect information when a user clicks a button on the main form of an application. You can see an example of this in the Visual C# Express Edition IDE. When you add a ListBox control to a form, you can click the Items property in the Properties window to display a dialog box. This dialog box enables you to quickly type text on separate lines of a text box. The application then adds each line of text to ListBox control when you click OK. If you want to let users add their own items to a list box in your application, you can create your own string editor dialog box.


Диалоговые окна

Извлечение данных из диалогового окна

 

Диалоговые окна позволяют программе взаимодействовать с пользователями и извлекать данные, введенные ими в диалоговое окно, в приложение. Существует несколько встроенных, доступных для использования в приложениях, диалоговых окон. Можно также создавать свои собственные диалоговые окна.

Стандартной задачей при разработке Windows Forms является отображение диалогового окна для сбора информации после нажатия пользователем кнопки в основной форме приложения. В следующем примере показано, как сделать это в Visual C#, экспресс-выпуск IDE. После добавления элемента управления ListBox в форму выберите свойство Элементы в окне Свойства для открытия диалогового окна. C помощью этого диалогового окна можно быстро ввести текст на нескольких строках текстового поля. После нажатия кнопки ОК приложение добавит каждую строку текста к элементу управления ListBox. Для того чтобы пользователи могли добавлять к списку произвольные элементы, необходимо создать свое собственное диалоговое окно редактора строк.


To create the main form of your application

1. On the File menu, click New Project.

The New Project dialog box appears.

2. Click Windows Forms Application, and then click OK.

A form named Form1 is added to the project.

3. From the Toolbox, drag a ListBox control to the form, and change the following property in the Properties window:

Property Value
Modifiers Public

4. Add a Button control to the form, and change the following properties in the Properties window:

Property Value
Name addItems
Text Add


Дата добавления: 2022-05-27; просмотров: 148;


Поиск по сайту:

Воспользовавшись поиском можно найти нужную информацию на сайте.

Поделитесь с друзьями:

Считаете данную информацию полезной, тогда расскажите друзьям в соц. сетях.
Poznayka.org - Познайка.Орг - 2016-2024 год. Материал предоставляется для ознакомительных и учебных целей.
Генерация страницы за: 0.007 сек.