User Control Resize

N

Newbie Coder

Hi All

VB.NET 2003

Can anyone tell me how to stop a user control being able to be resized
during both design time & run time, please?

I am looking for something like the LOCKED property, but being able to move
the control to wherever on the form it's needed.

Any ideas?

TIA
 
M

matt urbanowski

I don't think such a property exists. It would be in the Design
category of the properties window if there was one.

Matt
 
P

Phill W.

Newbie said:
Can anyone tell me how to stop a user control being able to be resized
during both design time & run time, please?

Read up on:

ParentControlDesigner (this is the best place to start in MSDN)
A base class from which you derive a "designer" for your UserControl.
Within the class, the SelectionRules property controls the
appearance/hiding of sizing handles on your UserControl - no sizing
handle, no design-time resizing!

DesignerAttribute
Used to link your UserControl to your "designer" class.

DefaultSize property
Sets the size of the UserControl when it is created at design time.

At Run-Time, you may have to override/shadow the Size, Height and Width
properties.

HTH,
Phill W.
 
M

Mudhead

Easy. Set the UserControls MaximumSize and MinimumSize properties to the
same value.
 
P

Phill W.

Good for you, but these properties are /new/ to VB 2005 and the O.P.
specifically stated they were still using VB 2003.

Good enough reason to upgrade? YMMV :)

Regards,
Phill W.
 
N

NickP

Or just set the size back again in the resize event, this is how I have done
it in the past.

Saves upgrading to 2005! haha.
 
N

Newbie Coder

Thank you Phil for your suggestions

I have used the Design Attribute & Shadowed the Height/Width properties, but
isn't enough

One question that has arose from your SIZE is that my control uses a Textbox
with border set to none, which makes the height 13 & won't allow me to
change to a height of 20/24. Any idea how? Setting height makes to anything
other than 13 is ignored

Anyway. Thanks again for your suggestions.

Newbie Coder
 
N

Newbie Coder

In the reside event I have set the size to the original, but this is ignored
in design time

I know Microsoft have had certain controls at least since VB 6 that the size
is locked at both design/run time

Thanks for the suggestion though Nick

BTW: I have VS.NET 2005 Pro, but this project was originally written in 1.1
& I am continuing to update it in the same Framework version.

Maybe, when I have a spare few coding weeks I will totally upgrade
everything to 2.0

Newbie Coder
 
N

NickP

Hi,

That's strange....

Always worked for me, just a second.....

http://nickpateman.m6.net/Files/resizecontroltest.zip

That will do ask you are after. Will prevent resizing during design
time as well as runtime. Although if you do it at run time it will probably
flicker, this is because the event is fired post resize.

In order to fix this, override the WM_SIZE method or use the other
methods posted in this thread. But this is the simplest solution.

Unless you have opposing anchors or docking set it will never resize at
runtime anyway....

Nick.
 
M

Mudhead

The height of the textbox is determined by it's font size. Make the font
bigger if you want to increase the height of the Textbox
 
N

Newbie Coder

Thanks for your reply

I want to keep the font 8.25 (standard), but increase the height

Newbie Coder
 
N

Newbie Coder

Oh I see.

You are working in VB.NET 2005 & I am using VB.NET 2003, which was the
version I mentioned in my original post.

Will take another look

Thank you once again, Nick

Newbie Coder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top