 |
|
| .NET DotNet Forum Index » VB.NET Forum (Visual Basic .NET) » Controls.Add Magnifying UserControl !?!?!?!?!... |
|
Page 1 of 1 |
|
| Author |
Message |
| eBob.com... |
Posted: Wed Nov 04, 2009 11:38 pm |
|
|
|
Guest
|
This is just driving me nuts. I have a really simple user control. It's
just a small textbox and small button. Created entirely in the designer.
No code. The size of the control is slightly less than 50x50. But after I
add it to a Panel, Panel.Controls.Add, it has a size of over 100x100 (but
less than the default user control size of 150,150). The textbox and button
are obviously about twice the size they should be. The object comes out of
the contructor the right size. In the next step I set the Location property
and after that the size is still OK. Then I add it to the panel and after
that the size has been corrupted and is over 100x100. If I change the code
to add a Label to the Panel, in place of the user control, that works fine.
If I add the user controls to the form, Me.Controls.Add, I have the same
problem. If I create a new but similar user control it has the same
problem.
I've created user controls before, but did I forget some step there?
How can a control have the right size immediately before calling
Controls.Add and the wrong size after that call?
Does anyone have any idea what might be going on?
Thanks, Bob |
|
|
| Back to top |
|
|
|
| eBob.com... |
Posted: Thu Nov 05, 2009 3:44 pm |
|
|
|
Guest
|
Thank you Johnny, that sounds like a good idea. However, I've had no joy.
I tried setting Dock and Anchor to None after New'ing the user control and
that had no apparent effect. So then I also tried setting Dock and Anchor
to None in the constructor of the user control, but still no joy.
I'm wondering if something in the project might be corrupted, so I will not
try to re-create everything in a new project.
But if you have any other ideas I'd still be interested.
Thanks again, Bob
"Johnny J." <johnny at (no spam) jcsoftwaresolutions.com> wrote in message
news:%23WtO$4fXKHA.412 at (no spam) TK2MSFTNGP04.phx.gbl...
Quote: Try setting
myUserControl.Dock = DockStyle.None
before adding it to the collection
Cheers,
Johnny J.
"eBob.com" <eBob.com at (no spam) totallybogus.com> skrev i meddelandet
news:OIYiVHdXKHA.1280 at (no spam) TK2MSFTNGP04.phx.gbl...
This is just driving me nuts. I have a really simple user control. It's
just a small textbox and small button. Created entirely in the designer.
No code. The size of the control is slightly less than 50x50. But after
I add it to a Panel, Panel.Controls.Add, it has a size of over 100x100
(but less than the default user control size of 150,150). The textbox
and button are obviously about twice the size they should be. The object
comes out of the contructor the right size. In the next step I set the
Location property and after that the size is still OK. Then I add it to
the panel and after that the size has been corrupted and is over 100x100.
If I change the code to add a Label to the Panel, in place of the user
control, that works fine. If I add the user controls to the form,
Me.Controls.Add, I have the same problem. If I create a new but similar
user control it has the same problem.
I've created user controls before, but did I forget some step there?
How can a control have the right size immediately before calling
Controls.Add and the wrong size after that call?
Does anyone have any idea what might be going on?
Thanks, Bob
|
|
|
| Back to top |
|
|
|
| Johnny J.... |
Posted: Thu Nov 05, 2009 3:59 pm |
|
|
|
Guest
|
I have a thought: After adding it to the panel, the usercontrol and the
contained controls will probably inherit the Font property from the
container control (i.e. the panel).
If that font has a size that is larger than the textbox's original font
size, it could force the textbox to change size to accomodate the larger
font.
Could that be it?
/Johnny J.
"eBob.com" <fakename at (no spam) totallybogus.com> skrev i meddelandet
news:ejiLYjlXKHA.4816 at (no spam) TK2MSFTNGP06.phx.gbl...
Quote: Thank you Johnny, that sounds like a good idea. However, I've had no joy.
I tried setting Dock and Anchor to None after New'ing the user control and
that had no apparent effect. So then I also tried setting Dock and Anchor
to None in the constructor of the user control, but still no joy.
I'm wondering if something in the project might be corrupted, so I will
not try to re-create everything in a new project.
But if you have any other ideas I'd still be interested.
Thanks again, Bob
"Johnny J." <johnny at (no spam) jcsoftwaresolutions.com> wrote in message
news:%23WtO$4fXKHA.412 at (no spam) TK2MSFTNGP04.phx.gbl...
Try setting
myUserControl.Dock = DockStyle.None
before adding it to the collection
Cheers,
Johnny J.
"eBob.com" <eBob.com at (no spam) totallybogus.com> skrev i meddelandet
news:OIYiVHdXKHA.1280 at (no spam) TK2MSFTNGP04.phx.gbl...
This is just driving me nuts. I have a really simple user control.
It's just a small textbox and small button. Created entirely in the
designer. No code. The size of the control is slightly less than 50x50.
But after I add it to a Panel, Panel.Controls.Add, it has a size of over
100x100 (but less than the default user control size of 150,150). The
textbox and button are obviously about twice the size they should be.
The object comes out of the contructor the right size. In the next step
I set the Location property and after that the size is still OK. Then I
add it to the panel and after that the size has been corrupted and is
over 100x100. If I change the code to add a Label to the Panel, in place
of the user control, that works fine. If I add the user controls to the
form, Me.Controls.Add, I have the same problem. If I create a new but
similar user control it has the same problem.
I've created user controls before, but did I forget some step there?
How can a control have the right size immediately before calling
Controls.Add and the wrong size after that call?
Does anyone have any idea what might be going on?
Thanks, Bob
|
|
|
| Back to top |
|
|
|
| eBob.com... |
Posted: Fri Nov 06, 2009 4:09 pm |
|
|
|
Guest
|
Another good thought Johnny. Thanks. But after posting my last note I
created a new project, created a new user control from scratch (luckly it's
very simple), did some copying and pasting to get the form1 stuff, and this
new project works fine. So ... unlikely as it might seem, I have to
conclude that somehow something in the project got corrupted.
Thanks again, Bob
"Johnny J." <johnny at (no spam) jcsoftwaresolutions.com> wrote in message
news:ewqmTrlXKHA.1372 at (no spam) TK2MSFTNGP02.phx.gbl...
Quote: I have a thought: After adding it to the panel, the usercontrol and the
contained controls will probably inherit the Font property from the
container control (i.e. the panel).
If that font has a size that is larger than the textbox's original font
size, it could force the textbox to change size to accomodate the larger
font.
Could that be it?
/Johnny J.
"eBob.com" <fakename at (no spam) totallybogus.com> skrev i meddelandet
news:ejiLYjlXKHA.4816 at (no spam) TK2MSFTNGP06.phx.gbl...
Thank you Johnny, that sounds like a good idea. However, I've had no
joy. I tried setting Dock and Anchor to None after New'ing the user
control and that had no apparent effect. So then I also tried setting
Dock and Anchor to None in the constructor of the user control, but still
no joy.
I'm wondering if something in the project might be corrupted, so I will
not try to re-create everything in a new project.
But if you have any other ideas I'd still be interested.
Thanks again, Bob
"Johnny J." <johnny at (no spam) jcsoftwaresolutions.com> wrote in message
news:%23WtO$4fXKHA.412 at (no spam) TK2MSFTNGP04.phx.gbl...
Try setting
myUserControl.Dock = DockStyle.None
before adding it to the collection
Cheers,
Johnny J.
"eBob.com" <eBob.com at (no spam) totallybogus.com> skrev i meddelandet
news:OIYiVHdXKHA.1280 at (no spam) TK2MSFTNGP04.phx.gbl...
This is just driving me nuts. I have a really simple user control.
It's just a small textbox and small button. Created entirely in the
designer. No code. The size of the control is slightly less than
50x50. But after I add it to a Panel, Panel.Controls.Add, it has a size
of over 100x100 (but less than the default user control size of
150,150). The textbox and button are obviously about twice the size
they should be. The object comes out of the contructor the right size.
In the next step I set the Location property and after that the size is
still OK. Then I add it to the panel and after that the size has been
corrupted and is over 100x100. If I change the code to add a Label to
the Panel, in place of the user control, that works fine. If I add the
user controls to the form, Me.Controls.Add, I have the same problem.
If I create a new but similar user control it has the same problem.
I've created user controls before, but did I forget some step there?
How can a control have the right size immediately before calling
Controls.Add and the wrong size after that call?
Does anyone have any idea what might be going on?
Thanks, Bob
|
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Fri Dec 04, 2009 6:51 pm
|
|