Setting Panel's LOCKED property in code
-
Hey Howzit? I was astonished to see that a person can't override or set a Panel's "LOCKED" property, how can I get around this? Regards,
-
Hey Howzit? I was astonished to see that a person can't override or set a Panel's "LOCKED" property, how can I get around this? Regards,
hi NewbieDude! :) actually, this is not a property of the panel. it's coming from the ToolBoxItem class. Anyway, if you want is to set the allowable selection on your panel (the icons to resize/move a panel in design-time), you must sub class the Windows.Forms.Design.ParentControlDesigner then override the SelectionRules property. In that property, you can set what selections are allowed. then use this designer on your customized panel by adding a Designer attribute on you panel.
public class MyDesigner : ParentControlDesigner
{
public MyDesigner ()
{}public override SelectionRules SelectionRules { get { return (SelectionRules.Locked | SelectionRules.Visible | SelectionRules.Moveable); } }
}
[Designer(typeof(MyDesigner))]
public class MyPanel : Panel
{
public MyPanel ()
{}
}hope that helps! :) microsoc :cool:
-
hi NewbieDude! :) actually, this is not a property of the panel. it's coming from the ToolBoxItem class. Anyway, if you want is to set the allowable selection on your panel (the icons to resize/move a panel in design-time), you must sub class the Windows.Forms.Design.ParentControlDesigner then override the SelectionRules property. In that property, you can set what selections are allowed. then use this designer on your customized panel by adding a Designer attribute on you panel.
public class MyDesigner : ParentControlDesigner
{
public MyDesigner ()
{}public override SelectionRules SelectionRules { get { return (SelectionRules.Locked | SelectionRules.Visible | SelectionRules.Moveable); } }
}
[Designer(typeof(MyDesigner))]
public class MyPanel : Panel
{
public MyPanel ()
{}
}hope that helps! :) microsoc :cool:
Hi there, I have created the new class MyDesigner using your code and created and then I have placed the attribute above my class but I am not familiar with all this, how do I actually lock the panel now?
-
Hi there, I have created the new class MyDesigner using your code and created and then I have placed the attribute above my class but I am not familiar with all this, how do I actually lock the panel now?
at design time, try to select your panel. haven't you notice that the selection is the same as when you set the lock property to true? you cannot resize it through dragging. if it's not what you want, can you elaborate more what you trying to do? thanks! :) microsoc :cool:
-
at design time, try to select your panel. haven't you notice that the selection is the same as when you set the lock property to true? you cannot resize it through dragging. if it's not what you want, can you elaborate more what you trying to do? thanks! :) microsoc :cool:
Hey, I am hosting windows forms designers (see the link below which has the code). In other words this application simulates .NET design time when its actually in run time. So all the rules change are far as properties etc. After you have checked out the code, what I wanna do is create a Panel in code, add it to this form (which is instantiated in the initialize method) and then LOCK the panel. http://www.divil.co.uk/net/articles/designers/hosting.asp
-
Hey, I am hosting windows forms designers (see the link below which has the code). In other words this application simulates .NET design time when its actually in run time. So all the rules change are far as properties etc. After you have checked out the code, what I wanna do is create a Panel in code, add it to this form (which is instantiated in the initialize method) and then LOCK the panel. http://www.divil.co.uk/net/articles/designers/hosting.asp
I took the MOVEABLE property out...IT WORKS>>>>YOU'RE THE MAN!
-
I took the MOVEABLE property out...IT WORKS>>>>YOU'RE THE MAN!