adding a property to user control
-
I have a user control inherited from a Panel. I'm trying to make it re sizable and movable(mostly done) I'd like to add a property to be able to lock the width or height or both. I'm not sure how to do it. The code below kind of gives the feeling of what I'm trying to do. Once again, my thanks goes out to this great board and its members.
public partial class PanelSizable : System.Windows.Forms.Panel { enum LockedType { Both, Width, Height, None }; private LockedType lockStatus = LockedType.None; public LockedType LockSize { get { return lockStatus; } set { lockStatus = value; } } ....
-
I have a user control inherited from a Panel. I'm trying to make it re sizable and movable(mostly done) I'd like to add a property to be able to lock the width or height or both. I'm not sure how to do it. The code below kind of gives the feeling of what I'm trying to do. Once again, my thanks goes out to this great board and its members.
public partial class PanelSizable : System.Windows.Forms.Panel { enum LockedType { Both, Width, Height, None }; private LockedType lockStatus = LockedType.None; public LockedType LockSize { get { return lockStatus; } set { lockStatus = value; } } ....
Ok, when you set the lock type the set method will execute, that should be known already.;P In the set method record the size of your control. Now make sure you have registered all resize events for the control (there are at least 3), when one of those events gets fired due to a resize of the control, set the size back to the locked values. The control will then "snap back". In case more than one resize event gets executed during a resize make sure that you pay attention which events get fired and attempt to reduce duplicate "snap backs" to improve performance.
█▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██