Re: Controls don't overlap on design form, but do at runtime by Randy
Randy
Wed Sep 10 09:10:51 CDT 2003
I have concluded that Anchoring and Docking are not what I need.
My form is set to Maximized.
I dropped this chunk of code into my Form1.h
private:
void Form1_Layout(Object* sender, System::Windows::Forms::LayoutEventArgs*
e) {
this->dataGrid1->Left = (8);
this->dataGrid1->Top = (8);
this->dataGrid1->Height = ((int) this->get_Height()*.48);
this->dataGrid1->Width = ((int) this->get_Width()*.96);
this->textBox1->Top = ((int) this->get_Height()*.50);
this->textBox1->Left = (8);
this->textBox1->Height = ((int) this->get_Height()*.48);
this->textBox1->Width = ((int) this->get_Width()*.92);
this->vScrollBar1->Top = ((int) this->get_Height()*.50);
this->vScrollBar1->Left = ((int) 8+this->get_Width()*.92);
this->vScrollBar1->Height = ((int) this->get_Height()*.48);
this->vScrollBar1->Width = ((int) this->get_Width()*.04);
}
This doesn't seem to have the desired effect, or any effect at all for this
matter. What am I missing?
Thanks
Randy Hersom
"Pete" <pvidler@gawab.com> wrote in message
news:_Jr7b.54$um1.93515@newsfep2-gui.server.ntli.net...
> Hi,
>
> Anchoring simply forces the edges of your control to maintain a certain
> distance from the given side of their parent. For your needs, you might
have
> to handle a Layout event for the controls involved. You might also want to
> look into Docking, if you haven't already done so.
>
> There's lots of info on layout using Anchoring/Docking/Custom methods on
the
> internet, I recommend you visit www.google.com.
>
> -- Pete
>
> Randy Hersom wrote:
> > I left a Microsft DevDays some months ago with the idea that if you
> > anchored all of your controls to all four sides, then the screen
> > would size up proportionally when the form was maximized or made
> > larger. My current test form most emphatically does not do this -
> > controls overlap on each other in a most ugly fashion. My scroll bar
> > next to a multi line text box ends up half the width of the screen.
> > The data grid on the top half and the edit box on the bottom half
> > both expand to well over half the screen. Does anybody have any
> > ideas on how to make a form size up gracefully?
>
>