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!

Designing question keep the form clean.

Status
Not open for further replies.

aspnetvbnetnerd

Programmer
Feb 3, 2008
31
0
0
SE
Ok, I have question I have been thinking about for a few weeks and if it is possible.

Let's say I have a menu like Outlook, 5 different menu.
I have a form and in that form and I have added a splitter menu
One splitter menu on the left (splitter_1) and one on the right (splitter_2). On the left I have created the outlook menu on left splitter menu.

I want the splitter_2 to be empty and I will create one dll with user design for every menu instead adding alot of

When the user click on Contacts menu I will call the the Contacts.dll and a specific form and Dock it to the splitter menu.

If you could doit like this then design will not be a mess.

Instead ot doing visible = false/true

Hope you understand what I am going with this.

George
 
If I understand it correctly:
You're writing a host form which will dynamically load various usercontrols, depending on which item the user picks from the Outlook-style bar.

That seems like a pretty clean way to do it. You'll need a factory object that knows how to return one, based on what the user chose, but that's straight-forward OO design work.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
you could also create a series of command objects and assign the command object to click event. the command object will have all the instructions on what should happen. in conjunction with the factory object above would create a very rich and extensible solution.

cude example
Code:
interface ICommand
{
   void Execute();
}

class ThisCommand : ICommand
{
   private ISomeTask task;

   public ThisCommand (ISomeTask task)
   {
      this.task = task;
   }

   public void Execute()
   {
      task.DoSomething();
   }
}

class ThatCommand : ICommand
{
   private ISomeOtherTask task;

   public ThatCommand(ISomeOtherTask task)
   {
      this.task = task;
   }

   public void Execute()
   {
      task.DoSomethingElse();
   }
}

public class CommandFactory()
{
   IDictionary<string, ICommand> listOfCommands;
   public CommandFactory()
   {
      listOfCommands = new IDictionary<string, ICommand>();
      listOfCommands["this"] = new ThisCommand(new SomeTask());
      listOfCommands["that"] = new ThatCommand(new SomeOtherTask());
   }

   public ICommand CreateCommandBasedOn(string key)
   {
      return listOfCommands[key];
   }
}
with this in place set the command argument of the menu item to key of the associated command. when the menu command event fires call the factory and execute.
Code:
void MenuItemCommandEvent(object sender, CommandEventArgs e)
{
   new CommandFactory().CreateCommandBasedOn(e.CommandArgument).Execute();
}

I'm a web app devleoper so i work with string keys alot. In a win app you may be able to objects instead and forgo the string keys.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for ther response.

So it is a good way to create Usercontrol.

And when a user clicks on a menu I use the code control.add(%usecontrolname%)?

Is this the approach you would use?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top