Click here to Skip to main content
15,881,702 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
http://farm9.staticflickr.com/8241/8487654049_f9be29062d_z.jpg[^]

This is Demon Tool Lite Preference window form i want to design same layout can anybody suggest how to achieve this?
Posted
Updated 18-Feb-13 23:33pm
v2

1 solution

You can use a list box with pictures [^] at the left hand side for the menu and when the selected index on the list box changes you can load another user control on the area on the right hand side.

Use the OnSelectedItemChanged - Event[^] of the list view to find out when the listbox' index was changed.
Use the area on the right to place there a panel and add your user control to the panel:

C#
//Add this line of code to your form loading method.
listbox.OnSelectedIndexChanged += new EventHandler(listbox_OnSelectedItemChanged);

//Add this method to the code behind of the form
private void listbox_OnSelectedItemChanged(object sender, EventArgs e)
{
   myPanel.Controls.Clear();//myPanel is the Panel where your user control is placed inside

   //MenuItemEnum is an Enum where you store your different menu item types
   //I preassume that the listbox is filled with members of the menuitemenum type.
   //Change this behavior if this should be not the case.
   if((MenutItemEnum)listbox.SelectedItem == MenuItemEnum.General)
   {
        YourUserControl yourUserControl = new YourUserControl();
        myPanel.Controls.Add(yourUserControl);
   }
}


cheers,
Marco Bertschi
 
Share this answer
 
v2
Comments
Surendra0x2 19-Feb-13 3:42am    
Can you tell me show to load a User control on listbox selecteditem?
Marco Bertschi 19-Feb-13 5:31am    
Added a code sample to the solution

cheers,
Marco Bertschi
Surendra0x2 19-Feb-13 6:27am    
Thanks a ton sir You're genius :)
one more thing plz help me in my usercontrol there is a button how to handle that button click event?
Marco Bertschi 19-Feb-13 7:02am    
Glad that I was able to help you.
Surendra0x2 19-Feb-13 6:43am    
i got how i can handle button click event thanks sir...
but how to apply icon and text both in the listbox ...:(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900