Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. adding a property to user control

adding a property to user control

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dino2094
    wrote on last edited by
    #1

    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; } } ....

    L 1 Reply Last reply
    0
    • D dino2094

      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; } } ....

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups