Reputation: 11
I'm anand. I have a problem about how to get text value in textbox in user control. I make a small application. I use Form1 as main form, and in the form I put one panel. In panel I will put custom user control that contain textbox. Now, I want to get the text on the textbox in user control and show it in the msgbox. Can anyone help me to fix this problem please?
Upvotes: 0
Views: 3068
Reputation: 569
As André Leal said in the comments. If you define a public property in your user control you will be able to access the value.
Public Property textboxValue as String
Get
Return MyTextBox.text
End Get
Set(value as String)
MyTextBox.text = value
End Set
End Property
Then you can access it using code like this.
YourUserControl.textboxValue
If you don't need to edit the value of the textbox you can make the property readonly as follows.
Public ReadOnly Property textboxValue as String
Get
Return MyTextBox.text
End Get
End Property
Upvotes: 2