Resolved Add item inside a Split container and fill

dv2020

Active member
Joined
Dec 18, 2020
Messages
30
Programming Experience
1-3
Hi,

I'm trying to add an item inside a split panel, then set the dock to fill. I have tried both methods below but not having any luck.

Tried setting the dock to fill, the moving it into the container panel.
1st Try - Code:
            crystalReportViewer1.Dock = DockStyle.Fill;
            splitContainer1.Panel2.Controls.Add(crystalReportViewer1);


Tried the moving it into the container panel, then setting the dock to fill.
Tried this:
    splitContainer1.Panel2.Controls.Add(crystalReportViewer1);
            crystalReportViewer1.Dock = DockStyle.Fill;

Any have any other things i could try?

Thanks

David
 
Solution
So what's the actual issue? Is the control not appearing at all or is it appearing but not docking? Please provide a FULL and CLEAR explanation: this is what I'm trying to do, this is how I'm trying to do it and this is what happens when I try.

Certainly the first option is the right one, in principle. You should always configure a control before adding it to a form. I just tried this code and it worked just as expected:
C#:
var btn = new Button {Text = "Click Me!", Dock = DockStyle.Fill};

splitContainer1.Panel2.Controls.Add(btn);
Does it work for you with other controls? I don't use CR so I can't test with a report viewer specifically but, really, you should already have tested with other controls to try to narrow down the...
So what's the actual issue? Is the control not appearing at all or is it appearing but not docking? Please provide a FULL and CLEAR explanation: this is what I'm trying to do, this is how I'm trying to do it and this is what happens when I try.

Certainly the first option is the right one, in principle. You should always configure a control before adding it to a form. I just tried this code and it worked just as expected:
C#:
var btn = new Button {Text = "Click Me!", Dock = DockStyle.Fill};

splitContainer1.Panel2.Controls.Add(btn);
Does it work for you with other controls? I don't use CR so I can't test with a report viewer specifically but, really, you should already have tested with other controls to try to narrow down the issue.
 
So what's the actual issue? Is the control not appearing at all or is it appearing but not docking? Please provide a FULL and CLEAR explanation: this is what I'm trying to do, this is how I'm trying to do it and this is what happens when I try.

Certainly the first option is the right one, in principle. You should always configure a control before adding it to a form. I just tried this code and it worked just as expected:
C#:
var btn = new Button {Text = "Click Me!", Dock = DockStyle.Fill};

splitContainer1.Panel2.Controls.Add(btn);
Does it work for you with other controls? I don't use CR so I can't test with a report viewer specifically but, really, you should already have tested with other controls to try to narrow down the issue.

Turns out, when using a crystal report I need to add it after refreshing the report. See below. Hopefully helps anyone else who comes across the issue using crystal reports and docking.

Fixed:
crystalReportViewer1.RefreshReport();
crystalReportViewer1.Dock = DockStyle.Fill;
splitContainer1.Panel1.Controls.Add(crystalReportViewer1);
[/CODE]
 
Solution
Back
Top Bottom