Make a control have a fixed size-VBForums
Results 1 to 4 of 4

Thread: Make a control have a fixed size

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Make a control have a fixed size

    I always used to override the onResize method, but I found this other thing on MSDN. It works for controls or forms:

    VB Code:
    1. 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)
    2.         MyBase.SetBoundsCore(x, y, 150, 75, specified)
    3.     End Sub

    that would make your control to have a fixed size of 150, 75 and the users cant resize it
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Use a designer

    Hi Mr. Polite.

    Another way would be to use a designer class.

    The designer has an overridable property called SelectionRules.
    In that you can manipulate wether the control can be resized, moved, or even selected.

    So, by using that, you can achieve the same as e.g. a label control with the AutoSize property set to true.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm could you show us how to use a designer class then? hehe seems nice
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Sure Thing

    Hi Mr. Polite.

    I have attached a small project containing a usercontrol, and a testproject.

    The usercontrol has a property called LockSize.
    The designer checks this property to determine wether the control can be resized or not.

    I hope you can use this.
    Attached Files Attached Files
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.