Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an options dialog for my WinApp. 1

Status
Not open for further replies.

d00ape

Programmer
Apr 2, 2003
171
SE
I’m about to create an options dialog that will be opened from my windows application main Forms menu.
I have many different “modules” in the application which each of them need to have an own options dialog. For sure this is a common situation.

I need some kind of “pattern” to create an Options dialog and add the other modules option dialogs in a tab-like way.

All tips of how I can do that in a clean way are welcomed!!


My next thing is to store all these settings (properties) in some kind of file and then restore the settings when my application runs next time. I’ve tried searched some articles but I really don’t know what to search on…
 
Consider each option tab a plugin. Create an interface that will provide a button name, image, and a UserControl. You can add each tab to the dialog from individual components that way.

public interface IOptionsTab
{
string Name;
UserControl GetOptionsPage();
}


Then on your options form you would have:

public void AddOptionsTab(IOptionsTab tab)
{
TabPage tp1 = new TabPage(); //if in a tab control
tp1.Controls.Add(tab.GetOptionsPage());
tp1.Text = tab.Name;
TabPage1.Pages.Add(tp1);
}

Then from each class (or module) you would add your tab page to the instance of your options dialog.

public class MyModule
{
public MyModule(OptionsDialog dlg)
{
dlg.AddOptionsTab(new MyModuleOptions);
}
}

MyModuleOptions would be the class that you write that implements the IOptionsTab interface.


Hope that gives you some ideas.
 
Perfect! You made me think in the right direction!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top