It seems the MS GUI designer is really bad at building GUIs at run time -- although may be I just don't know how to do it.
My particular problem should be simple. I've got a simple, SDI Form, part of whose contents depend on other parts. Simply put, if the user makes selections on the left part of the form, I mess with the right part. I remove and add Panels that are the right part, as needed.
The biggest problem is that the panels have different sizes (heights only). I account for this by manually changing the Form height, like this:
Bizarrely, as these controls get swapped in an out, they change size! So, the size of the form get's messed up. (As the code shows, I'm swapping the controls into/out of a cell of a [tt]TableLayoutPanel. [/tt] The cell changes size, but the controls aren't in the cell when it does so!)
What I'd really like are pointers to how to do this kind of thing. Also, if anyone uses third party .NET controls, do they handle this sort of thing better?
Thanks!
My particular problem should be simple. I've got a simple, SDI Form, part of whose contents depend on other parts. Simply put, if the user makes selections on the left part of the form, I mess with the right part. I remove and add Panels that are the right part, as needed.
The biggest problem is that the panels have different sizes (heights only). I account for this by manually changing the Form height, like this:
Code:
visibleControl.Visible = false;
outerPanel.Controls.Remove(visibleControl);
int heightDiff = neededControl.Size.Height - visibleControl.Size.Height + 2;
Size nowSize = ClientSize;
SetClientSizeCore(nowSize.Width, nowSize.Height + heightDiff);
outerPanel.Controls.Add(neededControl, 1,0);
neededControl.Visible = true;
Bizarrely, as these controls get swapped in an out, they change size! So, the size of the form get's messed up. (As the code shows, I'm swapping the controls into/out of a cell of a [tt]TableLayoutPanel. [/tt] The cell changes size, but the controls aren't in the cell when it does so!)
What I'd really like are pointers to how to do this kind of thing. Also, if anyone uses third party .NET controls, do they handle this sort of thing better?
Thanks!