473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 65264
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
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
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
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
by: Wang | last post by:
Here is the code for a webcontrol, quite simple: ------------------------------------------------------------------------------------------------------------- <%@ Control Language="c#"...
0
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
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
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
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
by: abdulazees | last post by:
when click button i want to print autometicaly reportveiwer data, i not need to show reportviewer.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.