I am making a custom button control and am having some difficulty with my Text property. Anything I type in only stays while the form designer window is open. When I close the form designer and reopen it, my Text property resets to “”. Also if I run the program, it loses the value entered at design time.
I also have an Image property for my control which is working just fine.
Here’s some of my code:
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class BlackButton
Private iText As String
Private iImage As Image
''' <summary>
''' Gets/Sets the text displayed in the button.
''' </summary>
<Browsable(True), Description("Gets or sets the text displayed on the button")> _
Public Shadows Property Text() As String
Get
Return iText
End Get
Set(ByVal value As String)
iText = value
ReDrawMe()
End Set
End Property
''' <summary>
''' Gets/Sets the image to be displayed on the button
''' </summary>
<Browsable(True), Description("Gets or sets the image displayed on the button")> _
Public Shadows Property Image() As Image
Get
Return iImage
End Get
Set(ByVal value As Image)
iImage = value
ReDrawMe()
End Set
End Property
I have carefully combed through my code and made sure I’m not resetting it anywhere.
Thanks in advance for any help on this.
It seems to work adding a property :