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. Setting Panel's LOCKED property in code

Setting Panel's LOCKED property in code

Scheduled Pinned Locked Moved C#
question
7 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.
  • N Offline
    N Offline
    NewbieDude
    wrote on last edited by
    #1

    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,

    M 1 Reply Last reply
    0
    • N NewbieDude

      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,

      M Offline
      M Offline
      microsoc
      wrote on last edited by
      #2

      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:

      N 1 Reply Last reply
      0
      • M microsoc

        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:

        N Offline
        N Offline
        NewbieDude
        wrote on last edited by
        #3

        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?

        M 1 Reply Last reply
        0
        • N NewbieDude

          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?

          M Offline
          M Offline
          microsoc
          wrote on last edited by
          #4

          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:

          N 1 Reply Last reply
          0
          • M microsoc

            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:

            N Offline
            N Offline
            NewbieDude
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • N NewbieDude

              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

              N Offline
              N Offline
              NewbieDude
              wrote on last edited by
              #6

              I took the MOVEABLE property out...IT WORKS>>>>YOU'RE THE MAN!

              M 1 Reply Last reply
              0
              • N NewbieDude

                I took the MOVEABLE property out...IT WORKS>>>>YOU'RE THE MAN!

                M Offline
                M Offline
                microsoc
                wrote on last edited by
                #7

                ok. I added that because i thought you only want to lock the resizing part.:-> anyway, nice to know that! :) happy coding! :) microsoc :cool:

                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