Geeks Talk

Prepare for your Next Interview




How do we catch click event?

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 ...


Go Back   Geeks Talk > Software Development > VB.NET

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-17-2007
Contributing Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 7 Times in 6 Posts
prakash.kudrekar is on a distinguished road
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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-20-2007
Junior Member
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
monica15568 is on a distinguished road
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
Reply With Quote
  #3 (permalink)  
Old 04-20-2007
Junior Member
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
monica15568 is on a distinguished road
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
Reply With Quote
  #4 (permalink)  
Old 04-29-2007
Contributing Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 7 Times in 6 Posts
prakash.kudrekar is on a distinguished road
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
Reply With Quote
  #5 (permalink)  
Old 04-29-2007
Contributing Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 7 Times in 6 Posts
prakash.kudrekar is on a distinguished road
Re: How do we catch click event?

Hi Monica,

Thanks.. I could execute ur commands
Reply With Quote
  #6 (permalink)  
Old 04-30-2007
Junior Member
 
Join Date: Apr 2007
Location: hyderabad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
subhadra.p is on a distinguished road
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()
{
......
.....
}
Reply With Quote
Reply

  Geeks Talk > Software Development > VB.NET


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 12:32 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved