How to alter between to different fields with a checkbox?

Viewed 75

I am designing a windows form in C# and there is a checkbox called "electronic delivery". Under it is a field for "email address". Now I would like to add the option that the email field is only visible if checkbox is checked. If checkbox is not checked, I would like to have a different field there. I know how to handle this on the code side, to make things visible/hidden, but how do I place the fields in the form? Should I place one on top of another? Then I won't be able to access the one below to change it's properties. Or should I keep only one filed and change it's name inside the code?

3 Answers

You could place your controls in FlowLayoutPanel control. The FlowLayoutPanel control arranges its contents dynamically in a horizontal or vertical flow direction.

enter image description here

You could just place them one on top of the other as you suggested. You said you did not want to do this because it would make selecting the properties of the controls difficult.

You can select a control from the combobox drop down menu on the properties section of Visual Studio.

enter image description here

You should create two Different Panels and Add Objects based on the Requirement. After Put visible and Hide Code in the Check Box Checked Event. Try Panels it Will Work. You can Simple Move Panel Along with all you objects which make it super Easy.

Related