private void AddListItemForPage(OptionsPage page) { int imageIndex = 0; var image = page.Image; if (image != null) { imageList.Images.Add(image); imageIndex = imageList.Images.Count - 1; } var item = new ListViewItem(page.Title, imageIndex); item.Tag = page; listView.Items.Add(item); }
private void AddPage(OptionsPage page, ref Size maxPageSize) { panelPage.Controls.Add(page); AddListItemForPage(page); // Adjust to fit the largest child page. if (page.Width > maxPageSize.Width) { maxPageSize.Width = page.Width; } if (page.Height > maxPageSize.Height) { maxPageSize.Height = page.Height; } // Set page.Dock *after* looking at its size. page.Dock = DockStyle.Fill; page.Visible = false; }
private void listView_SelectedIndexChanged(object sender, System.EventArgs e) { if (_activePage != null) { _activePage.Visible = false; } if (listView.SelectedItems.Count != 0) { var selectedItem = listView.SelectedItems[0]; var page = (OptionsPage)selectedItem.Tag; _activePage = page; } if (_activePage != null) { _activePage.Visible = true; _activePage.OnSetActive(); } }