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 / Design Time / February 2007

Tip: Looking for answers? Try searching our database.

How to lock controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Allen - 21 Feb 2007 02:10 GMT
Hi there,

I'm creating a design form at runtime using
"System.ComponentModel.Design.DesignSurface" and cousins. Does anyone know
how to lock an individual control on my form (or possibly all controls) so
users can't drag or resize it. Thanks.
RobinS - 21 Feb 2007 02:17 GMT
myForm.Locked = True

myControl.Locked = True

Robin S.
---------------------------------
> Hi there,
>
> I'm creating a design form at runtime using
> "System.ComponentModel.Design.DesignSurface" and cousins. Does anyone
> know how to lock an individual control on my form (or possibly all
> controls) so users can't drag or resize it. Thanks.
John Allen - 21 Feb 2007 02:25 GMT
> myForm.Locked = True
>
> myControl.Locked = True

Thanks. Neither "Form" nor "Control" has a "Locked" property however. What
am I missing.
RobinS - 21 Feb 2007 06:05 GMT
What version of Visual Studio are you using? I'm using VS2005, and those
properties are there.

Robin S.
-----------------------------------
>> myForm.Locked = True
>>
>> myControl.Locked = True
>
> Thanks. Neither "Form" nor "Control" has a "Locked" property however.
> What am I missing.
John Allen - 21 Feb 2007 11:50 GMT
> What version of Visual Studio are you using? I'm using VS2005, and those
> properties are there.

This isn't being done in Visual Studio. It's taking place at runtime on a
machine where VS isn't installed. I'm manually creating the same design form
seen in VS using "System.ComponentModel.Design.DesignSurface" as my starting
point. I can create my form without issue but don't know how to kill the
sizing grips that automatically appear on each control (nor how to disable
dragging of each control). The "Locked" property seen in VS is some sort of
dynamic (design-time) property which isn't an official member of "Control"
or "Form". I'm not sure how to access this property at runtime assuming it's
even there (maybe it's added behind the scenes). If not then there must be
some other way to pull this off.
John Allen - 21 Feb 2007 12:56 GMT
> This isn't being done in Visual Studio. It's taking place at runtime on a
> machine where VS isn't installed. I'm manually creating the same design
[quoted text clipped - 6 lines]
> runtime assuming it's even there (maybe it's added behind the scenes). If
> not then there must be some other way to pull this off.

Ok, I can do it using reflection like so:

TypeDescriptor.GetProperties(myControl)["Locked"].SetValue(myControl, true);

This seems highly irregular however. Is there a more mainstream way to do it
or is this it. Thanks.

Rate this thread:







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.