P
PR
Hello,
I'm creating a Windows control that includes a few textboxes. In the form
designer, I want there to be one property that drops down into a few
sub-values for the different text boxes, somewhat akin to how Location and
Size usually work for many standard controls.
(There may be more appropriate ways to do this, but I'm kind of doing it as
a self-tutorial.)
I've tried creating a Property which returns a Structure declared within the
custom control class, but that doesn't seem to work. The form designer
simply represents the Value property in grayed-out text reading
"ctlPhoneNumberTextBox.PhoneNumberTextBox+PhoneNumber". Any ideas?
Here's a code snippet, if it helps:
***
Public Class PhoneNumberTextBox
Inherits System.Windows.Forms.UserControl
Private areaCodeStr As String
Private exchangeStr As String
Private suffixStr As String
Private extensionStr As String
Public Structure PhoneNumber
Public AreaCode As String
Public Exchange As String
Public Suffix As String
Public Extension As String
End Structure
Property Value() As PhoneNumber
Get
Dim returnPhoneNumber As PhoneNumber
returnPhoneNumber.AreaCode = areaCodeStr
returnPhoneNumber.Exchange = exchangeStr
returnPhoneNumber.Suffix = suffixStr
returnPhoneNumber.Extension = extensionStr
Return returnPhoneNumber
End Get
Set(ByVal Value As PhoneNumber)
areaCodeStr = Value.AreaCode
exchangeStr = Value.Exchange
suffixStr = Value.Suffix
extensionStr = Value.Extension
End Set
End Property
I'm creating a Windows control that includes a few textboxes. In the form
designer, I want there to be one property that drops down into a few
sub-values for the different text boxes, somewhat akin to how Location and
Size usually work for many standard controls.
(There may be more appropriate ways to do this, but I'm kind of doing it as
a self-tutorial.)
I've tried creating a Property which returns a Structure declared within the
custom control class, but that doesn't seem to work. The form designer
simply represents the Value property in grayed-out text reading
"ctlPhoneNumberTextBox.PhoneNumberTextBox+PhoneNumber". Any ideas?
Here's a code snippet, if it helps:
***
Public Class PhoneNumberTextBox
Inherits System.Windows.Forms.UserControl
Private areaCodeStr As String
Private exchangeStr As String
Private suffixStr As String
Private extensionStr As String
Public Structure PhoneNumber
Public AreaCode As String
Public Exchange As String
Public Suffix As String
Public Extension As String
End Structure
Property Value() As PhoneNumber
Get
Dim returnPhoneNumber As PhoneNumber
returnPhoneNumber.AreaCode = areaCodeStr
returnPhoneNumber.Exchange = exchangeStr
returnPhoneNumber.Suffix = suffixStr
returnPhoneNumber.Extension = extensionStr
Return returnPhoneNumber
End Get
Set(ByVal Value As PhoneNumber)
areaCodeStr = Value.AreaCode
exchangeStr = Value.Exchange
suffixStr = Value.Suffix
extensionStr = Value.Extension
End Set
End Property