Drop down list -> show different controls?

  • Thread starter Frank K. Jensen
  • Start date
F

Frank K. Jensen

Hi guys,

First a warming: I am completely new in C#, so please don't take any
knowledge, I should, have for granted :)

Ok, down to business.
I have a windows form with a drop down list. Depending on the choice in the
drop down list, I would like to have an area below with different controls
(buttons, numeric up/down etc.) to show up. Right now I have made one of
these control areas and grouped them in a panel. I then hidde the panel
(visible = false) until one of the items in the drop down list is chosen, in
which case I set visible = true.
This works quite well, however I now have to design the control areas for
all the other options, and if I just do that in the same form, they will all
be on top of each other and it will be quite messy. I would like the control
area to somehow be detached from the main form.

What should I look at? Some keywords or links to a tutorial would be great.

Best regards,
Frank
 
A

Arne Vajhøj

First a warming: I am completely new in C#, so please don't take any
knowledge, I should, have for granted :)

Ok, down to business.
I have a windows form with a drop down list. Depending on the choice in
the drop down list, I would like to have an area below with different
controls (buttons, numeric up/down etc.) to show up. Right now I have
made one of these control areas and grouped them in a panel. I then
hidde the panel (visible = false) until one of the items in the drop
down list is chosen, in which case I set visible = true.
This works quite well, however I now have to design the control areas
for all the other options, and if I just do that in the same form, they
will all be on top of each other and it will be quite messy. I would
like the control area to somehow be detached from the main form.

What should I look at? Some keywords or links to a tutorial would be great.

Multiple panels - one for each choice - and just one visible??

Or maybe redesign to a tab control & tab pages??

Arne
 
F

Frank K. Jensen

"Peter Duniho" skrev i meddelelsen
As Arne suggests, a TabControl may be appropriate here, if you have only a
few choices in the drop-down. In that case, you would remove the
drop-down altogether and just let the user make their selection by
clicking on the appropriate tab.

Good suggestion, but tab pages will not be very nice in this application.
Also, I use tab pages for something else in the same window.
If you prefer the general UI design you've got now, you can address the
Designer-related issues by using UserControl. These are essentially Panel
instances that can be edited individually in the Visual Studio Designer,
similar in fashion to Form instances.

This sounds like what I need.
Once they have been designed and compiled, you can then insert them into
any Form instance via the Designer. And as long as they are in the same
Solution where you want to use them, they will appear in the Toolbox,
above all the other Forms controls. They can just be dragged from there
into whatever Form designer you want.

Thanks for the short and excellent explanation. I had actually tried to make
a UserControl, but I couldn't figure out how to use it. Now I can (I
think... well time will tell :))

Thanks to both of you again.
Best regards,
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top