I have a quick question regarding windows forms. Say I have a main form and it has a toolstrip with 2 buttons on it. Lets say one button displays a calendar form in the main form and the other displays a list of contacts in the main form. What is the best way to do this? Do i need to hide the one form when another form link is clicked or is there an easier way to do this? I just want more than one form to be shown in the mainform buy clicking on the corresponding button. Also the calendar and contact form will actually be in a splitcontainer panel inside the main form.

It really depends how you want to do this, if you want to display both the calender and contact information in the "Main Form", one by one, then you can show & hide the related component accordingly, e.g. if you click on the calender then contact form or details would be hidden or cleared, depending again whether you want to save the data or not before changing the focus to other item.
However, if you want to display both of these together then FLow Panel is the best option as it will show whatever you want, accordingly, as it arranges the components itself. All you would have to do this, is to add the components in the flp.controls.add(component);, as you would be adding the components depending on the buttons or components event on the tool strip you can add different components to this panel.

HTH

Thanks

It really depends how you want to do this, if you want to display both the calender and contact information in the "Main Form", one by one, then you can show & hide the related component accordingly, e.g. if you click on the calender then contact form or details would be hidden or cleared, depending again whether you want to save the data or not before changing the focus to other item.
However, if you want to display both of these together then FLow Panel is the best option as it will show whatever you want, accordingly, as it arranges the components itself. All you would have to do this, is to add the components in the flp.controls.add(component);, as you would be adding the components depending on the buttons or components event on the tool strip you can add different components to this panel.

HTH

Thanks

One more quick question. I've been researching on the web and do you think I should make different user controls or make a form for each screen (calendar/contacts). Both of them can be added to panel1.Controls.Add(xxxxx). What do people usually do? I am trhinking making a user control because the form seems kind of like a hack job. Whats your opinion?

Well, if you are using hide() and show() behind the buttons or whatever controls you are using, to control the displaying of calendar and contact information, then you would not need different forms unless you need to restrict some user to view particular forms (calendar/contacts), if so you can only allow to show them the related ones, otherwise, having one form with changing components behind the appropriate buttons should do.

HTH

This article has been dead for over six months. Start a new discussion instead.