Я пытаюсь написать настраиваемый элемент управления в первый раз. По существу, я создаю группу «значков», используя наследуемую панель, которую пользователи могут щелкнуть, чтобы открыть определенные формы. Класс содержит экземпляр PictureBox и две метки:Как показать запись в текстовом поле в панели свойств
Однако, я обнаружил, что мне нужно, чтобы быть в состоянии использовать что-то похожее на «VbCrLF» в описании строки так, чтобы при вводе предметов, он добавляет текст к следующей строке, а не позволяет описанию продолжать работать. То, что я хотел бы сделать, это при вводе нового txtDescription или txtHeaderDescription, позвольте мне нажать enter и включить в него каретки для меня. Этикетка изначально делает это так:
Мой вопрос, как я могу изменить свой класс в VS, чтобы показать, что тип поле ввода, а не типичная запись «линии»?
Мой класс:
Public Class WorkspaceIconControl
Inherits Panel
Dim pbIcon As New PictureBox
Dim lblHeader As New Label, lblDescrip As New Label
Public Sub New()
'MODIFY THE BACKCOLOR
Me.BackColor = Color.SteelBlue
Me.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
Me.Width = 250
Me.Height = 100
Me.BorderStyle = BorderStyle.FixedSingle
'ADD PICTUREBOX
pbIcon.BackColor = System.Drawing.Color.Transparent
pbIcon.Image = My.Resources.addressIcon2
pbIcon.Dock = DockStyle.None
pbIcon.Width = 96
pbIcon.Height = 96
pbIcon.Top = 5
pbIcon.SizeMode = PictureBoxSizeMode.StretchImage
Me.Controls.Add(pbIcon)
'ADD HEADER
lblHeader.Font = New System.Drawing.Font("Calibri", 12.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
lblHeader.Name = "lblHeader"
lblHeader.Text = "txtHeader"
lblHeader.Top = 15
lblHeader.Left = 95
lblHeader.Width = 300
lblHeader.ForeColor = Color.White
Controls.Add(lblHeader)
'ADD DESCRIP
lblDescrip.Font = New System.Drawing.Font("Calibri", 7.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
lblDescrip.Name = "lblDescrip"
lblDescrip.Text = "txtDescription"
lblDescrip.Top = 35
lblDescrip.Left = 95
lblDescrip.Width = 300
lblDescrip.ForeColor = Color.White
Me.Controls.Add(lblDescrip)
End Sub
<Description("The image associated with the picturebox of this control"), _
Category("Appearance")> _
Public Property MyImage() As Image
Get
Dim image1 As Image
image1 = pbIcon.Image
Return image1
End Get
Set(ByVal imgValue As Image)
pbIcon.Image = imgValue
End Set
End Property
<Description("The width of picturebox associated with the control"), _
Category("Appearance")> _
Public Property PictureBoxWidth() As Double
Get
Dim width As Double
width = pbIcon.Width
Return width
End Get
Set(ByVal widthVal As Double)
pbIcon.Width = widthVal
End Set
End Property
<Description("The height of picturebox associated with the control"), _
Category("Appearance")> _
Public Property PictureBoxHeight() As Double
Get
Dim height As Double
height = pbIcon.Height
Return height
End Get
Set(ByVal height As Double)
pbIcon.Height = height
End Set
End Property
<Description("The label header visible property associated with the control"), _
Category("Appearance")> _
Public Property HeaderVisible() As Boolean
Get
Dim bHeader As Boolean
bHeader = lblHeader.Visible
Return bHeader
End Get
Set(ByVal bHeader As Boolean)
lblHeader.Visible = bHeader
End Set
End Property
<Description("The label description text property associated with the control"), _
Category("Appearance")> _
Public Property txtDescription() As String
Get
Dim strText As String
strText = lblDescrip.Text
Return strText
End Get
Set(ByVal strText As String)
lblDescrip.Text = strText
End Set
End Property
<Description("The label description header text property associated with the control"), _
Category("Appearance")> _
Public Property txtHeaderDescription() As String
Get
Dim strText As String
strText = lblHeader.Text
Return strText
End Get
Set(ByVal strText As String)
lblHeader.Text = strText
End Set
End Property
End Class
меня ваш ответ на работу, но для будущей справки я не совсем уверен, как смотреть на исходный код элемента управления меткой. Это не часть дизайнера? –
@JasonBayldon Вы можете использовать [Free .NET Decompiler и Assembly Browser] (http://www.jetbrains.com/decompiler/) или попробовать [библиотеки .NET Framework] (http://referencesource.microsoft.com/netframework. ASPX) – LarsTech