473,387 Members | 1,834 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,387 software developers and data experts.

Activating a controls event from another control....


I'm have a little trouble understanding how to do this, but what i wanna do is have it so when the user clicks on an item in the menustrip,
it activates the column click event in a listview that i have on the form. In VB6 it wasn't very hard, but VB.Net is bit different and can't
figureout how to do it.... Anyway, when the user clicks on the menustrip item:

Private Sub ToolStripMenuItem3_Click(ByVal _
sender As System.Object, ByVal e As _
System.EventArgs) Handles _
ToolStripMenuItem3.Click

'Code sends click event to column...

End Sub

It'll activate the column click event...

Private Sub lstvFiles_ColumnClick _
(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.ColumnClickEventArgs) _
Handles lstvFiles.ColumnClick

'Do whatever..

End Sub

I'd like to send '2' as the column being "clicked" (out of the 3 columns 0,1,2 that i have) when the user clicks the menu strip item and
having trouble figuring out what arguments i'm supposed to fill in for 'sender' and 'e'.
Any help would be appriciated.

-george

Oct 25 '08 #1
2 2302
What you normally do is simply add the Handles clause for the control to the
Sub for that control. A Sub can have multiple Handles clauses, as follows:

Private Sub lstvFiles_ColumnClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ColumnClickEventArgs) Handles lstvFiles.ColumnClick,
ToolStripMenuItem3.Click

Doing this will have this Sub handle both the lstvFiles.ColumnClick and
ToolStripMenuItem3.Click events. The parameters for the Sub must obviously
be compatible, which they are in this case since
System.Windows.Forms.ColumnClickEventArgs inherits System.EventArgs. If you
do want to call one from the other by having separate Subs, you can do
something like the following:

Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles ToolStripMenuItem3.Click
'If desired, you can declare new variables here of type System.Object and
System.Windows.Forms.ColumnClickEventArgs and set their properties instead
of passing sender and e
Me.lstvFiles_ColumnClick(sender,e)
End Sub

Hopefully this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"george" <2h*******@wiahroi3aj.jwowrote in message
news:lp********************************@4ax.com...
>
I'm have a little trouble understanding how to do this, but what i wanna
do is have it so when the user clicks on an item in the menustrip,
it activates the column click event in a listview that i have on the form.
In VB6 it wasn't very hard, but VB.Net is bit different and can't
figureout how to do it.... Anyway, when the user clicks on the menustrip
item:

Private Sub ToolStripMenuItem3_Click(ByVal _
sender As System.Object, ByVal e As _
System.EventArgs) Handles _
ToolStripMenuItem3.Click

'Code sends click event to column...

End Sub

It'll activate the column click event...

Private Sub lstvFiles_ColumnClick _
(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.ColumnClickEventArgs) _
Handles lstvFiles.ColumnClick

'Do whatever..

End Sub

I'd like to send '2' as the column being "clicked" (out of the 3 columns
0,1,2 that i have) when the user clicks the menu strip item and
having trouble figuring out what arguments i'm supposed to fill in for
'sender' and 'e'.
Any help would be appriciated.

-george

Oct 26 '08 #2

Ah, many thanks. Got it working from your help.

-george
On Sat, 25 Oct 2008 20:58:14 -0400, "Nathan Sokalski" <nj********@hotmail.comwrote:
>What you normally do is simply add the Handles clause for the control to the
Sub for that control. A Sub can have multiple Handles clauses, as follows:

Private Sub lstvFiles_ColumnClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ColumnClickEventArgs) Handles lstvFiles.ColumnClick,
ToolStripMenuItem3.Click

Doing this will have this Sub handle both the lstvFiles.ColumnClick and
ToolStripMenuItem3.Click events. The parameters for the Sub must obviously
be compatible, which they are in this case since
System.Windows.Forms.ColumnClickEventArgs inherits System.EventArgs. If you
do want to call one from the other by having separate Subs, you can do
something like the following:

Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles ToolStripMenuItem3.Click
'If desired, you can declare new variables here of type System.Object and
System.Windows.Forms.ColumnClickEventArgs and set their properties instead
of passing sender and e
Me.lstvFiles_ColumnClick(sender,e)
End Sub

Hopefully this helps.
Oct 26 '08 #3

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

Similar topics

9
by: wASP | last post by:
Hello again to all of you geniuses, I'm having a problem trying to load dynamic controls at the initialization phase. I've read the docs, and I thought I had it figured out:...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
2
by: Rubble | last post by:
Hello, Ive searched all over the net trying to find an answer to this...so anybody with some expertise in this area would be greatly appreciated. Background: I have a webform that loads a...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
1
by: weboweb | last post by:
Hello aspnet experts! I have a design question for the more experienced developers (more than me at least :-)). 1) I have a page in the application I'm building that displays a web user...
0
by: John Smith | last post by:
I still have not gotten this damn thing figured out and I'm asking for help one last time before I give up on it. I have a user control that contains a paged gridview control. The master page...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.