|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Button eventHi,
I've got a main module that instantiates a form and then does form.showdialog. The form has a button. I want the main module to respond to a click event from the button. I'm having trouble. I tried declaring the button with events in the module and added a handler, but it didn't trigger. I then made my own event in the form, raised in inside the button's click event and put a handler for that in the module. Again no good. Obviously I'm missing something. Can anyone help me do this? Art "Art" <A**@discussions.microsoft.com> schrieb: Private WithEvents Button1 As Button> I've got a main module that instantiates a form and then does > form.showdialog. > > The form has a button. I want the main module to respond to a click event > from the button. I'm having trouble. > > I tried declaring the button with events in the module and added a > handler, > but it didn't trigger. I then made my own event in the form, raised in > inside the button's click event and put a handler for that in the module. > Again no good. .... Dim f As New Form1() Button1 = f.Button1 f.Show() .... Private Sub Button1_Click( _ ByVal sender As Object, ByVal e As EventArgs _ ) Handles Button1.Click MsgBox("Hello world!") End Sub /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
Thank you very much -- it worked very well. I think I got confused as to which object I needed to declare with events. Thanks again, Art Show quoteHide quote "Herfried K. Wagner [MVP]" wrote: > "Art" <A**@discussions.microsoft.com> schrieb: > > I've got a main module that instantiates a form and then does > > form.showdialog. > > > > The form has a button. I want the main module to respond to a click event > > from the button. I'm having trouble. > > > > I tried declaring the button with events in the module and added a > > handler, > > but it didn't trigger. I then made my own event in the form, raised in > > inside the button's click event and put a handler for that in the module. > > Again no good. > > Private WithEvents Button1 As Button > .... > Dim f As New Form1() > Button1 = f.Button1 > f.Show() > .... > Private Sub Button1_Click( _ > ByVal sender As Object, ByVal e As EventArgs _ > ) Handles Button1.Click > MsgBox("Hello world!") > End Sub > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > >
Password Protect
DataBinding with Unbound Columns and calling EndCurrentEdit ListBox Problem firing a dts package's execution How To Show Partial Classes as a Hierarchy in Solution Explorer? Limit ComboBox entry to ipaddress format XML WebSvc Proxy Code Syntax Questions get the month (number) and year value from a date HOW Change Password Updating a dataadapter |
|||||||||||||||||||||||