UserControl inherit from label

P

Pascal

Hello
How to set the minimum size, the dock comportement of a usercontrol herited
from a label ?
i tried this without success :
Imports System.ComponentModel

<ToolboxBitmap(GetType(MyLblCtrl.MonLabel), "MonLabel.bmp")> _

Public Class MonLabel

Inherits Windows.Forms.Label

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.AllowDrop = True

Me.BorderStyle = Windows.Forms.BorderStyle.FixedSingle

Me.MinimumSize.Width = 80 'error here

Me.Dock = DockStyle.Fill

Me.Height = 25

End Sub







































http://www.scalpa.info
http://scalpa98.blogspot.com/
 
J

Jack Jackson

Hello
How to set the minimum size, the dock comportement of a usercontrol herited
from a label ?
i tried this without success :
Imports System.ComponentModel

<ToolboxBitmap(GetType(MyLblCtrl.MonLabel), "MonLabel.bmp")> _

Public Class MonLabel

Inherits Windows.Forms.Label

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.AllowDrop = True

Me.BorderStyle = Windows.Forms.BorderStyle.FixedSingle

Me.MinimumSize.Width = 80 'error here

Me.Dock = DockStyle.Fill

Me.Height = 25

End Sub

The MinimumSize property is an instance of the Size class, which does
not allow its properties to be modified. Create a new instance:

Me.MinimumSize = New Size(80, Me.MinimumSize.Height)
or
Me.MinimumSize = New Size(80, 0)
 
A

Armin Zingler

Pascal said:
Hello
How to set the minimum size, the dock comportement of a usercontrol
herited
from a label ?
i tried this without success :
....

Me.MinimumSize.Width = 80 'error here

Doesn't work because reading Me.MinimumSize returns a copy of the size. It's
a copy because the size is a value type (a Structure). Setting the Width of
the copy would not change the MinimumSize property. Therefore the error.
Assign a new Size object: Me.MinimumSize = new size(80, minimumsize.height)

Also set Me.Autosize = False. Otherwise Dock property doesn't have an
effect.


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

icon for UserControl 4

Top