Prepare for your Next Interview
This is a discussion on How do we catch click event? within the VB.NET forums, part of the Software Development category; Have a small query in VB .Net. How do we catch click event? Let me give example to make it clear I have form1 with button in it. in form ...
|
|||
|
How do we catch click event?
Have a small query in VB .Net.
How do we catch click event? Let me give example to make it clear I have form1 with button in it. in form I m creating form2. form1.vb ----------- public sub button_click() din frm2 as new form2 frm2.show() end sub In form2 I am creating button2. form2.vb ---------- sub form2_load() dim btn2 as new button2 me.controls.add(btn2) end sub When i run the program from1 with button will be displayed initially. when i click the button form2 with button will be created. My requirement is when i click the button in the form2 I need to handle some function. How do we do that? Since I am creating the button at the run time i don't have default function (Which we get when we create button in the from1.design and double click on it) Sorry for the Long question, I just wanted to get the question clear.. Please can anyone provide me the solution for it?? Thanks Prakash |
| Sponsored Links |
|
|||
|
Re: How do we catch click event?
'add this code where u create a new dynamic control dim cntrl as new button me.controls.add(cntrl) addhandler cntrl.click, addressof button2click private sub button2click(byval sender as object, byval e as system.eventargs) messagebox.show("button2click") end sub
|
|
|||
|
Re: How do we catch click event?
Dim cntrl as new button me.controls.add(cntrl) 'add this code where you add new dynamic controls addhandler cntrl.click, addressof button2click private sub button2click(byval sender as object, byval e as system.eventargs) messagebox.show("button2click") end sub
|
|
|||
|
Re: How do we catch click event?
Hi Monica,
Thanks for your reply. I am not clear abt the addhandler Actually i am a starter, so please can you make provide the code snippet?? addhandler cntrl.click, addressof button2click private sub button2click(byval sender as object, byval e as system.eventargs) messagebox.show("button2click") end sub Can you edit in the correct form Please? regards Prakash |
|
|||
|
Re: How do we catch click event?
hi
i have gone through your question u r requirement is to provide functionality to button within form2 which u have created in runtime. solution:we can use java script functiion to provide functionality to btn in frm2 by writing code within html page of that form switch to html page <input type="button" id="b2".... onclick="f1()"> using javascript write code for f1 fonction f1() { ...... ..... } |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code to click on 6 button | Geek_Guest | QTP | 8 | 09-16-2007 01:39 PM |
| Event Effect Graph | Srikanth | Testing Issues | 2 | 07-04-2007 04:02 AM |
| textbox TextChanged Event | Geek_Guest | ASP.NET | 1 | 03-15-2007 03:04 AM |
| Menu found disappeared and Right click does not work | sagar007 | Geeks Lounge | 0 | 02-21-2007 04:29 AM |