473,503 Members | 6,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Click button by code

Hi, I'm try to learn vb.net.

in delphi have .click method for click button by coding.
Can I do that with vb.net

Thank you very much.
Apr 10 '07 #1
12 65278
On Apr 10, 10:34 am, "Thammarat charoenchai." <apa...@gmail.com>
wrote:
Hi, I'm try to learn vb.net.

in delphi have .click method for click button by coding.
Can I do that with vb.net

Thank you very much.
myButton.PerformClick()

Thanks,

Seth Rowe

Apr 10 '07 #2
Call the method that handles the Click event of the button you want to click
and pass it sender and e.

If the function/sub that you want to call the button click from isn't
already being passed send As Object and e as System.EventArgs then you will
have to Dim/declare out your own.

Dim sender as Object
Dim e as System.EventArgs
btnAdd_Click( sender, e)

'This is the sub/method that gets called when the button is clicked
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click

' Some code goes here

End Sub

'Here is an example that already is being passed sender and e As
System.EventArgs
Private Sub ContextMenuStrip1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ContextMenuStrip1.Click

'Some code

'Click the button
btnAdd_Click( sender, e)
End Sub

Hope that helps,

Chris

"Thammarat charoenchai." <ap****@gmail.comwrote in message
news:ua**************@TK2MSFTNGP04.phx.gbl...
Hi, I'm try to learn vb.net.

in delphi have .click method for click button by coding.
Can I do that with vb.net

Thank you very much.

Apr 10 '07 #3
This works perfectly - but what if you want to actually see the button
visually being pressed?

Cheers,
Johnny J.
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
On Apr 10, 10:34 am, "Thammarat charoenchai." <apa...@gmail.com>
wrote:
>Hi, I'm try to learn vb.net.

in delphi have .click method for click button by coding.
Can I do that with vb.net

Thank you very much.

myButton.PerformClick()

Thanks,

Seth Rowe

Apr 10 '07 #4
That's much easier :o)
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
On Apr 10, 10:34 am, "Thammarat charoenchai." <apa...@gmail.com>
wrote:
>Hi, I'm try to learn vb.net.

in delphi have .click method for click button by coding.
Can I do that with vb.net

Thank you very much.

myButton.PerformClick()

Thanks,

Seth Rowe

Apr 10 '07 #5
It's working, but have some problem. This is my code

Private Sub frmProducts_FormClosing(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
MyBase.FormClosing
Dim ee As System.EventArgs

btnSave_ItemClick(sender, ee)

End Sub
when build project it's show

Warning 1 Variable 'ee' is used before it has been assigned a value. A
null reference exception could result at runtime.
C:\Project\HiStore\HiStore\frmProducts.vb 30 35 HiStore

What does it mean ?

Thank you very much
Apr 10 '07 #6
Try

Dim ee As System.EventArgs=New System.EventArgs

/Johnny J.
"Thammarat charoenchai." <ap****@gmail.comwrote in message
news:e2**************@TK2MSFTNGP03.phx.gbl...
It's working, but have some problem. This is my code

Private Sub frmProducts_FormClosing(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
MyBase.FormClosing
Dim ee As System.EventArgs

btnSave_ItemClick(sender, ee)

End Sub
when build project it's show

Warning 1 Variable 'ee' is used before it has been assigned a value. A
null reference exception could result at runtime.
C:\Project\HiStore\HiStore\frmProducts.vb 30 35 HiStore

What does it mean ?

Thank you very much

Apr 10 '07 #7
Perfect!!

Thank you very much. :D
Apr 10 '07 #8
On Apr 10, 11:17 am, "Johnny J?rgensen" <j...@altcom.sewrote:
Try

Dim ee As System.EventArgs=New System.EventArgs

/Johnny J.

"Thammarat charoenchai." <apa...@gmail.comwrote in message

news:e2**************@TK2MSFTNGP03.phx.gbl...
It's working, but have some problem. This is my code
Private Sub frmProducts_FormClosing(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
MyBase.FormClosing
Dim ee As System.EventArgs
btnSave_ItemClick(sender, ee)
End Sub
when build project it's show
Warning 1 Variable 'ee' is used before it has been assigned a value. A
null reference exception could result at runtime.
C:\Project\HiStore\HiStore\frmProducts.vb 30 35 HiStore
What does it mean ?
Thank you very much
Or he can just do btnSave_ItemClick(sender EventArgs.Empty) and avoid
the variable declaration.

Thanks,

Seth Rowe

Apr 10 '07 #9
This works perfectly - but what if you want to actually see the button
visually being pressed?
Good Question! Perhaps you could do this by passing the appropriate
windows messages to the button via the windows api, but I don't know
if that would work. If you need this behavior you will probably need
to do a userdrawn button and just draw the "pressed" image before you
call the PerformClick method.

Thanks,

Seth Rowe

On Apr 10, 11:04 am, "Johnny Jörgensen" <j...@altcom.sewrote:
This works perfectly - but what if you want to actually see the button
visually being pressed?

Cheers,
Johnny J.

"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:11**********************@o5g2000hsb.googlegro ups.com...
On Apr 10, 10:34 am, "Thammarat charoenchai." <apa...@gmail.com>
wrote:
Hi, I'm try to learn vb.net.
in delphi have .click method for click button by coding.
Can I do that with vb.net
Thank you very much.
myButton.PerformClick()
Thanks,
Seth Rowe
Apr 10 '07 #10
"Johnny Jörgensen" <jo**@altcom.seschrieb:
This works perfectly - but what if you want to actually see the button
visually being pressed?
<URL:http://dotnet.mvps.org/dotnet/code/controls/#PressButton>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Apr 10 '07 #11
"Thammarat charoenchai." <ap****@gmail.comschrieb:
It's working, but have some problem. This is my code

Private Sub frmProducts_FormClosing(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
MyBase.FormClosing
Dim ee As System.EventArgs

btnSave_ItemClick(sender, ee)
='btnSave_ItemClick(sender, EventArgs.Empty)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Apr 10 '07 #12
On Apr 10, 12:22 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"Johnny Jörgensen" <j...@altcom.seschrieb:
This works perfectly - but what if you want to actually see the button
visually being pressed?

<URL:http://dotnet.mvps.org/dotnet/code/controls/#PressButton>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thanks for the link Herfried, I was just going through pinvoke.net
trying to find the appropriate message values - now I have to get back
to work :-(

Thanks,

Seth Rowe

Apr 10 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4758
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
0
1598
by: [Yosi] | last post by:
I search solution for a little bit strange problem , I working on an application which includes a button. Click on this button will create number of threads each one execute deferent executable...
5
6801
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
3
2503
by: Wang | last post by:
Here is the code for a webcontrol, quite simple: ------------------------------------------------------------------------------------------------------------- <%@ Control Language="c#"...
0
1361
by: radders | last post by:
Hi guys, What I'd like to do is place three edit boxes with three static text labels on a click button. This would let the user input RGB values to the three edit boxes and then click the...
3
1941
by: eddie69 | last post by:
Hi, Newbie question here: I am creating an application in VB Studio 2005 which reads the status of an USB PIR Motion sensor. So far, I have managed to get the application to read the motion...
4
11054
by: nittin14 | last post by:
hi guys i m a beginner in Asp.net can u tell me that how to open page in new window after click button as well as i want to pass some data from this page. thanks
5
1937
by: laziers | last post by:
Hi, anyone know how to write a single-cilick button? I use this: <asp:button id="ButtonAdd" runat="server" text="Anuluj" onclick="Click_ButtonAdd" /> if ( !isPostBack){...
0
2240
by: abdulazees | last post by:
when click button i want to print autometicaly reportveiwer data, i not need to show reportviewer.
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.