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. Visual Basic
  4. Hide a property that isn't overridable...

Hide a property that isn't overridable...

Scheduled Pinned Locked Moved Visual Basic
csharppythoncomhelp
7 Posts 4 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
    Nick Rioux
    wrote on last edited by
    #1

    I'm creating a control and don't want it to be resizable. Most people say to hide it from the designer and throw an error when it's called, but I can't do that because the Size property isn't overrideable! Right now I set the size back the the default height and width in the resize event, but this may be confusing to the user as it looks resizable. Thanks, Nick


    Fluent in VB, Attempts to speak C#, Python, English ;)
    ---
    File Association in VB.Net

    O T 2 Replies Last reply
    0
    • N Nick Rioux

      I'm creating a control and don't want it to be resizable. Most people say to hide it from the designer and throw an error when it's called, but I can't do that because the Size property isn't overrideable! Right now I set the size back the the default height and width in the resize event, but this may be confusing to the user as it looks resizable. Thanks, Nick


      Fluent in VB, Attempts to speak C#, Python, English ;)
      ---
      File Association in VB.Net

      O Offline
      O Offline
      originSH
      wrote on last edited by
      #2

      In c# it's the 'new' modifier. http://msdn2.microsoft.com/en-us/library/435f1dw2(VS.80).aspx[^] Not sure about VB.Net though.

      N 1 Reply Last reply
      0
      • O originSH

        In c# it's the 'new' modifier. http://msdn2.microsoft.com/en-us/library/435f1dw2(VS.80).aspx[^] Not sure about VB.Net though.

        N Offline
        N Offline
        Nick Rioux
        wrote on last edited by
        #3

        Thanks! I ran the example code there through a translator and found out you use the shadows keyword.


        Fluent in VB, Attempts to speak C#, Python, English ;)
        ---
        File Association in VB.Net

        O 1 Reply Last reply
        0
        • N Nick Rioux

          Thanks! I ran the example code there through a translator and found out you use the shadows keyword.


          Fluent in VB, Attempts to speak C#, Python, English ;)
          ---
          File Association in VB.Net

          O Offline
          O Offline
          originSH
          wrote on last edited by
          #4

          great :D

          L 1 Reply Last reply
          0
          • O originSH

            great :D

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            not great, but shadows !

            Luc Pattyn [My Articles] [Forum Guidelines]

            O 1 Reply Last reply
            0
            • N Nick Rioux

              I'm creating a control and don't want it to be resizable. Most people say to hide it from the designer and throw an error when it's called, but I can't do that because the Size property isn't overrideable! Right now I set the size back the the default height and width in the resize event, but this may be confusing to the user as it looks resizable. Thanks, Nick


              Fluent in VB, Attempts to speak C#, Python, English ;)
              ---
              File Association in VB.Net

              T Offline
              T Offline
              TwoFaced
              wrote on last edited by
              #6

              You can easily fix a controls size by overriding SetBoundsCore. It looks like this.

              Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As System.Windows.Forms.BoundsSpecified)
                  Const fixedWidth As Integer = 50
                  Const fixedHeight As Integer = 50
              
                  MyBase.SetBoundsCore(x, y, fixedWidth, fixedHeight, specified)
              End Sub
              

              I know changing the size back in the resize event will also work, but doing it that way actually allows the control's size to be changed and then it quickly changes it back. Overriding SetBoundsCore will prevent the change from ever occurring.

              1 Reply Last reply
              0
              • L Luc Pattyn

                not great, but shadows !

                Luc Pattyn [My Articles] [Forum Guidelines]

                O Offline
                O Offline
                originSH
                wrote on last edited by
                #7

                :rolleyes:

                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