Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2004

Tip: Looking for answers? Try searching our database.

Lock size property problems in a custom control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GG - 30 Jul 2004 08:41 GMT
I made a custom control and I want to make impossible to resize it.
I follow these steps:
- I use a ControlDesigner (overridden SelectionRules)
- I hide the public Size property and make it readonly
- I override the protected DefaultSize property

and I achieve the correct behaviour in the designer.

The problem is that at runtime the control is many times bigger the size specified in the size property and I don't understand where this wrong size is read.

Does anyone found this problem yet?

Thanks in advance
Mick Doherty - 30 Jul 2004 09:48 GMT
Instead of hiding and making ReadOnly the Size property, modify the OnResize
method so that your fixed size is restored.

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
   MyBase.Size = New Size(50, 23)
End Sub

protected override void OnResize(EventArgs e)
{
   base.Size = new Size(50, 23);
}

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> I made a custom control and I want to make impossible to resize it.
> I follow these steps:
[quoted text clipped - 5 lines]
>
> The problem is that at runtime the control is many times bigger the size specified in the size property and I don't understand where this wrong size
is read.

> Does anyone found this problem yet?
>
> Thanks in advance
GG - 30 Jul 2004 10:31 GMT
Thanks Mick but I found another solution: in the constructor of the control I insert

this.Bounds = new Rectangle(this.Location.X, this.Location.Y, this.defaultSize.Width, this.defaultSize.Height);

and now all things works properly.

I forgot to mention that i'm working with compact framework so the defaultSize property is not available.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.