Question [:: ToolStripMenuItem click detection - How? ::]

Trusted

New member
Joined
Jul 1, 2010
Messages
4
Programming Experience
Beginner
Hello all,

I want my program to detect and do something when ToolStripMenuItem is clicked.

Can anyone please help me with the sample code???

Thanks in advance,
Trusted
 
You can create a Sub, and name it "ToolStripButton1_Click".
Also include "Handles" as well as which event this method should run on. In this case it runs on "ToolStripButton1.Click"

VB.NET:
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        MsgBox("You clicked on Button1")
    End Sub
 
Hi Mas,
Thanks for your reply.

I am sorry for explaining my question well. My code is as follows:

----------------------
Private Sub mycolor()

Dim clr(9)
clr(0) = Drawing.Color.Violet
clr(1) = Drawing.Color.Tomato
clr(2) = Drawing.Color.Teal
clr(3) = Drawing.Color.DeepPink
clr(4) = Drawing.Color.Blue
clr(5) = Drawing.Color.Gold
clr(6) = Drawing.Color.Red
clr(7) = Drawing.Color.Yellow
clr(8) = Drawing.Color.Green
clr(9) = Drawing.Color.Fuchsia

For i = 1 To 50
Me.BackColor = clr(Rnd() * 9)
Next
End Sub
----------------

I am already using a sub. I want to use an IF condition saying that IF ToolStripMenuItem is clicked, then Run the code above. And If other ToolStripMenuItem is Clicked, Stop.

Hope you understand what I am on.

Trusted
 
You want to start the loop from 1 to 50 by clicking a button,
and stop the loop (if it it still running) by clicking another button?
Is this what you are trying to do?
 
Oh yes!

And also I want the loop [which is already in PRIVATE SUB] to start when a button is clicked on ToolStripMenu. I could not able to use click event cause I cannot use Private Sub under another Private Sub.

Trusted
 

Latest posts

Back
Top