Dynamic Button where click closes form (RESOLVED)
Hi, I am trying to write a a windows app where the close button is created via a public class. The click event is created in here as well.
I can get the click event to process but I can not get the click event to close the form.
Please help!!
Code for class looks like
Public Class SetFormv
Public Sub Set_Form(ByVal in_frm As System.Windows.Forms.Form)
Dim btnClose As New Button
btnClose.Text = "Close"
btnClose.DialogResult = DialogResult.OK
AddHandler btnClose.Click, AddressOf BtnClose_Click
in_frm.Controls.Add(btnClose)
End Sub
Public Sub BtnClose_Click(ByVal sender As Object, ByVal e As EventArgs)
' This procedure handles events raised by the object Obj.
EndSub
EndClass
End Sub
End Class
Hi, I am trying to write a a windows app where the close button is created via a public class. The click event is created in here as well.
I can get the click event to process but I can not get the click event to close the form.
Please help!!
Code for class looks like
Public Class SetFormv
Public Sub Set_Form(ByVal in_frm As System.Windows.Forms.Form)
Dim btnClose As New Button
btnClose.Text = "Close"
btnClose.DialogResult = DialogResult.OK
AddHandler btnClose.Click, AddressOf BtnClose_Click
in_frm.Controls.Add(btnClose)
End Sub
Public Sub BtnClose_Click(ByVal sender As Object, ByVal e As EventArgs)
' This procedure handles events raised by the object Obj.
EndSub
EndClass
End Sub
End Class
Last edited: