Exercises
173
Create a
Load event handler that uses the following code to initialize the dialog. This
code selects the proper session in the
ListView control and then makes the control
scroll if necessary so that session is visible.
// Initialize the selection.
private void PickSessionForm_Load(object sender, EventArgs e)
{
sessionsListView.SelectedIndices.Add(SessionIndex);
// Ensure that the selection is visible.
sessionsListView.SelectedItems[0].EnsureVisible();
}
In the OK button’s
Click event handler, use the following code to save the selected
item’s index and title for the main form to use:
// Save the user’s selection.
private void okButton_Click(object sender, EventArgs e)
{
SessionIndex = sessionsListView.SelectedIndices[0];
SessionTitle = sessionsListView.SelectedItems[0].Text;
}
You can download the solutions to these exercises from the book’s web page at
www.wrox.com or www.CSharpHelper.com/24hour.html. They can be found in
the Lesson13 folder in the download.
596906c13.indd 173 4/7/10 12:32:50 PM
Click here to Play
596906c13.indd 174 4/7/10 12:32:50 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.206.69