Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have ribbon menu and below a panel. and i wont show different- different content in panel on clicked ribbon menu different- different button in windows form .

how can i do this ..... please help me ...
Posted
Comments
BillWoodruff 26-Mar-14 5:07am    
Does this mean you want to show different Controls on the Panel when different elements on the Ribbon Menu are clicked ? Are there any Controls that you want to show on the Panel at ALL times ?
mukesh mourya 26-Mar-14 5:11am    
sr i am new for it show just difficulty with me to make as please help me ...
mukesh mourya 26-Mar-14 5:16am    
no sr i don't wont to show any controls show in panel all time .

i wont to like m s office type . in which, when clicked on any menu controls then in below panel element are change according element
please guide me how can i do

1 solution

Have you thought about using a Ribbon Control ? It seems to me that what you want is functionality like that. There's a good CodeProject article on how to use a non-Microsoft Ribbon Control: [^]. Also see: [^]. For WPF: [^]
In this case, I don't think you want a drop-down Menu, but a ToolStrip Control. So put, a ToolStrip Control on your Form, and add four Buttons to it.

Note: I have not used any of these Ribbon Controls.

To make a "cheap" kind-of-a-ribbon interface: I suggest that you create/design a series of Panels, one Panel for each separate top-level ToolStripMenuItem, each of the same size, and appearance. Each panel will, of course, display Controls for the functionality you wish that specific Panel to present to the user.

For example, create Panels named: PanelFile, PanelEdit, PanelTools, PanelHelp, etc.

As you are designing, you can spread these Panels out on your Form for ease of working with them.

When you have all the Panels designed, then select them all, click F4 to get to the Properties menu, and set their Anchor properties to Left+Top+Right. Make sure that the Panel you wish the user to see when the Application starts is "on top" of all the other Panels.

I'd align all the Panels in code, but you could certainly do that manually at design time.

Now, go through your ToolStrip Buttons and double-click on each one, and in the EventHandler that is generated, put the code to bring the appropriate Panel to the front of the z-order.

So, the code in my Form might look something like this:
C#
private Point panelInitialLocation;

 private void Form2_Load(object sender, EventArgs e)
 {
     // position all the Panels beneath the ToolStrip
     panelInitialLocation = new Point(0,toolStrip1.Bottom);

     PanelFile.Location = panelInitialLocation;
     PanelEdit.Location = panelInitialLocation;
     PanelTools.Location = panelInitialLocation;
     PanelHelp.Location = panelInitialLocation;

     // select the Panel the user will see when the application is started
     PanelFile.BringToFront();
 }

 // user clicks the File ToolStripButton on the ToolStrip
 private void tsBtnFile_Click(object sender, EventArgs e)
 {
     PanelFile.BringToFront();
 }

 private void tsBtnEdit_Click(object sender, EventArgs e)
 {
     PanelEdit.BringToFront();
 }

 private void tsBtnTools_Click(object sender, EventArgs e)
 {
     PanelTools.BringToFront();
 }

 private void tsBtnHelp_Click(object sender, EventArgs e)
 {
     PanelHelp.BringToFront();
 }
 
Share this answer
 
v2
Comments
mukesh mourya 26-Mar-14 7:02am    
sir this method (code) is not working as i wont.
BillWoodruff 26-Mar-14 9:23am    
You need to tell me what you have done, and what specific errors you are seeing, for me to help you.
mukesh mourya 26-Mar-14 7:05am    
OK ... sir how can i show form in mainform panel (like iframe in web html ).
BillWoodruff 26-Mar-14 9:23am    
Is this a Windows Forms application ?
mukesh mourya 26-Mar-14 12:14pm    
ya sir, this is win form.

ok. i explain it.

in my win forms, i have a ribbon menu in above and a panel in below.
ribbon menu have 3 button (add record, update Record, View Record )

and i wont, when user clicked on add record button(which are in ribbon menu) then

for add new Record , some text-boxes (which are make by me ) show in below panel .

and when user are clicked on Update Record then

some element are show those panel( also on those place) and hide previous panel content (add record button content)

(just like tab control type )

sorry for bad English....


please help me
Improve solution Permalink

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