Hallo Experts,
I have made a User Control containing Button1and textbox1
Then added the following code to the control:
__________________________
__________
__________
__
Public Class button_panel
Inherits System.Windows.Forms.UserC
ontrol
Public Property txtValue() As String
Get
Return TextBox1.Text
End Get
Set(ByVal value As String)
TextBox1.Text = value
End Set
End Property
End Class
__________________________
__________
__________
__
In the form I have the code:
__________________________
__________
__________
_
Private Sub ModularPortal_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Create_buttons()
Create_buttons()
End Sub
Private MNButtonCount As Integer = 0
Private Sub Create_buttons()
Dim NewButton As New button_panel()
NewButton.Location = New System.Drawing.Point(12, 204 + MNButtonCount)
AddHandler NewButton.Click, AddressOf alfa
Me.mnupanel.Controls.Add(N
ewButton)
MNButtonCount += 100
End Sub
Public Sub alfa(ByVal sender As Object, ByVal e As EventArgs)
sender.txtValue = "OK"
End Sub
__________________________
__________
__________
__________
__
When running, 2 buttons and2 textfields is made, with background from the User Control.
By clicking on one of the buttons, "Public Sub alfa" is not triggered.
If I click on the panel beside the buttons on the background from the User Control. "Public Sub alfa" is triggered and writing back to the correct User Control text field.
How do I redirect the button click event to trigger Public Sub alfa ?
Start Free Trial