Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# ПІДРУЧНИКИ / c# / Manning - Windows.forms.programming.with.c#.pdf
Скачиваний:
108
Добавлен:
12.02.2016
Размер:
14.98 Mб
Скачать

The following steps detail the changes required to display our two dialogs.

 

 

 

 

DISPLAY THE PROPERTY DIALOGS

 

 

 

 

 

 

 

 

 

 

Action

Result

 

 

 

 

 

 

 

1

 

In the MainForm.cs [Design]

 

 

 

window, add two buttons to the

 

 

 

form as shown in the graphic.

 

 

 

 

Settings

 

 

 

 

 

 

 

 

 

 

Button

Property

Value

 

 

 

album

(Name)

btnAlbumProp

 

 

 

 

Anchor

Top, Right

 

 

 

 

Text

Propertie&s

 

 

 

photo

(Name)

btnPhotoProp

 

 

 

 

Anchor

Top, Right

 

 

 

 

Text

Properti&es

 

 

 

 

 

 

 

 

2

 

Add a Click event handler for

private void btnAlbumProp_Click

 

 

album’s Properties button.

(object sender, System.EventArgs e)

 

 

 

 

 

 

{

 

 

How-to

 

 

 

using (AlbumEditDlg dlg

 

 

a. Within this handler, display an

= new AlbumEditDlg(_album))

 

 

{

 

 

Album Properties dialog box

 

 

if (dlg.ShowDialog()

 

 

for the current album.

== DialogResult.OK)

 

 

b. If the user modifies the prop-

{

 

 

_bAlbumChanged = true;

 

 

erties, mark the album as

 

 

UpdateList();

 

 

changed and update the list.

}

 

 

 

 

 

 

}

 

 

 

 

 

 

}

 

 

 

 

 

 

 

3

 

Add a Click event handler for

private void btnPhotoProp_Click

 

 

the photograph’s Properties

(object sender, System.EventArgs e)

 

 

button to display the

{

 

 

if (_album.Count == 0)

 

 

PhotoEditDlg form.

 

 

return;

 

 

How-to

 

 

 

if (lstPhotos.SelectedIndex >= 0)

 

 

a Within the handler, if the

 

 

{

 

 

album is empty then simply

_album.CurrentPosition

 

 

return.

 

 

= lstPhotos.SelectedIndex;

 

 

 

 

}

 

 

b. Set the current position in the

 

 

 

 

 

album to the selected photo-

using (PhotoEditDlg dlg

 

 

graph.

 

 

= new PhotoEditDlg(_album))

 

 

 

 

{

 

 

c. Display a Photo Properties

 

 

if (dlg.ShowDialog()

 

 

dialog box for the photograph

== DialogResult.OK)

 

 

at the current position.

{

 

 

_bAlbumChanged = true;

 

 

d. If the user modifies the prop-

 

 

UpdateList();

 

 

erties, mark the album as

}

 

 

changed and update the list.

}

 

 

}

 

 

 

 

 

 

 

 

 

 

 

 

 

324

CHAPTER 10 LIST CONTROLS

Соседние файлы в папке c#