Highlighted
Absent Member.
Absent Member.
2683 views

Multiple panels on a Winform

Jump to solution

I'm attempting to add multiple panels onto a winform, some of which overlap.

I'm finding that the later panels that have been added refuse to appear even though the statement:

set Panelx::Visible to TRUE

is given

What am I doing wrong?

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Multiple panels on a Winform

Jump to solution

I am attaching an example of how to do this with user controls.

This sample has a simple form with two radio buttons and a panel.

Depending on which radio button is selected, the appropriate usercontrol will be added to the panel.

Pressing the getData button at the bottom will get all the text fields from both user controls using properties and format a multiline textbox using the data.

View solution in original post

0 Likes
5 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Multiple panels on a Winform

Jump to solution

What may be happening is that your second panel has been created such that it is a child of the first panel instead of the form itself. That would make panel1 the container and if it was invisible then panel2 would also be invisible.

If you are creating the two panels using the Winform Designer then make sure that the top left hand corner of panel2 does not lie within panel1 or it will generate the code-behind such that panel1 is the container for panel2.

If you look in the .designer.cbl file for the form and see code like the following it means that panel1 is the container for panel2

     *>
     *> panel1
     *>
      invoke panel1::Controls::Add(panel2)
      ...

You should instead see:

*>
*> Form1
*>
    set self::ClientSize to new System.Drawing.Size( 384 362)
   
invoke self::Controls::Add(panel1)
   
invoke self::Controls::Add(panel2)

Thanks.,

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Multiple panels on a Winform

Jump to solution

So to clarify...

Having muliple panels on a WINFORM is fine just as long as the top left hand corner of each created panel does not lie within another panel??

If thats the case what is the best way to approach the problem whereby on the left hand side of the form I have a listbox containing 30 entries. Depending on WHICH of the entries I choose a different set of input variables appear on the right hand side of the form.

As you can appreciate I have to overlay a great number of panels in order to then allow this process to work as a single form but if theres another way.....??

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Multiple panels on a Winform

Jump to solution

It may be better to look at using either a tabControl, where you set up a different TabPage for each set of input fields or create a User Control for each of the panels and add the required user control dynamically depending on the option selected.

The later would probably be the easiest to maintain.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Multiple panels on a Winform

Jump to solution

I am attaching an example of how to do this with user controls.

This sample has a simple form with two radio buttons and a panel.

Depending on which radio button is selected, the appropriate usercontrol will be added to the panel.

Pressing the getData button at the bottom will get all the text fields from both user controls using properties and format a multiline textbox using the data.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Multiple panels on a Winform

Jump to solution

Excellent job.

Much appreciated.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.