So everyone knows a very popular way to display settings now is to have a ListView on the left with options that changes a Panel on the right, when clicked.
Several years ago, I came across one way to easily manage this is to create a TabControl, put the controls for each settings category in the tab page during design time, because it makes it easy to switch tabs and edit the pages.
During run time, when the settings page is opened, you create Panels for each TabPage, move the controls from the TabPage to its corresponding panel and add the Text (title) of each TabPage into the ListView on the left. And then, if you want, you can destroy the TabControl to free up memory.
The problem I am having is that as my code iterates through the controls on a TabPage, it won't add some of them. In my case, they are all CheckBoxes at the moment, so I'm confused as to why some would not be moved. During debug, I can check TabPage.Controls and all CheckBoxes are there, but as it iterates, it just doesn't add some of the controls to the Panel.
I have an image of how I have this setup during DesignTime, what it looks like at RunTime, and what my code is that is handling the move from TabPages to Panels.
Does anyone have any ideas why this may be happening? I'm stumped.
DesignTime: http://ift.tt/19LTkhK
RunTime: http://ift.tt/1xDQfeT
public void setPanels()
{
foreach (TabPage tab in tabSettingGroups.TabPages)
{
Panel panel = new Panel()
{
Dock = DockStyle.Fill,
Visible = true
};
ListViewItem lvi = new ListViewItem(tab.Text)
{
Tag = panel
};
lvwOptions.Items.Add(lvi);
foreach (Control ctrl in tab.Controls)
{
panel.Controls.Add(ctrl);
}
}
//Destroy TabControl to free up memory
tabSettingGroups.Dispose();
}
Aucun commentaire:
Enregistrer un commentaire