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

How to call an Event ?

Hi,
How can I call an event from an action.
Example, I want to call the datagrid.Double.click event when a button is
pressed.

Stan.
Nov 20 '05 #1
5 1647
I forgot to say I use a class inherit from datagrid, so I can not call
RaiseEvent.

Stan
Nov 20 '05 #2
* "Stan Sainte-Rose" <st**@cyber972.com> scripsit:
How can I call an event from an action.
Example, I want to call the datagrid.Double.click event when a button is
pressed.


Why not put the code from the handler into a separate procedure and call
this procedure from the handler and the button's 'Click' event handler?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Herfried,

In fact, I use this bit of code and I want when I press the Enter key from a
datagrid to raise the DoubleClick
And as I have many datagrids I think it's not really cool to write a
procedure for each datagrid.
Public Class DataGridEnter
Inherits DataGrid
Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As
Boolean
If msg.WParam.ToInt32() = CInt(Keys.Enter) Then
------- Raise my Event..
Return True
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function 'ProcessCmdKey

End Class

Stan

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> a écrit dans le
message de news:bu************@ID-208219.news.uni-berlin.de...
* "Stan Sainte-Rose" <st**@cyber972.com> scripsit:
How can I call an event from an action.
Example, I want to call the datagrid.Double.click event when a button is
pressed.


Why not put the code from the handler into a separate procedure and call
this procedure from the handler and the button's 'Click' event handler?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
"Stan Sainte-Rose" <st**@cyber972.com> schrieb
Hi,
How can I call an event from an action.
Example, I want to call the datagrid.Double.click event when a button
is pressed.


You can not call an event, but you can call the same procedure that you call
in the double-clicke event handler.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
Stan,
If you are deriving from a control (or other class) you can raise a base
event, by calling a special a special protected method. For example the
DataGrid.DoubleClick event is raised by the DataGrid.OnDoubleClick method.
This DoubleClick/OnDoubleClick relationship is a standard design pattern in
..NET that I would recommend you follow in your own classes. For details see:

http://msdn.microsoft.com/library/de...Guidelines.asp

http://msdn.microsoft.com/library/de...Guidelines.asp
You would need something like:

Public Class DataGridEnter
Inherits DataGrid

Protected Overrides Function ProcessCmdKey( _
ByRef msg As System.Windows.Forms.Message, _
ByVal keyData As System.Windows.Forms.Keys) _
As Boolean
If msg.WParam.ToInt32() = CInt(Keys.Enter) Then
MyBase.OnDoubleClick(EventArgs.Empty)
Return True
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function 'ProcessCmdKey

End Class

Note in VB.NET your OnMyEvent method can simply call RaiseEvent MyEvent, as
RaiseEvent will check to see if there are any handlers...

Hope this helps
Jay

"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
Hi,
How can I call an event from an action.
Example, I want to call the datagrid.Double.click event when a button is
pressed.

Stan.

Nov 20 '05 #6

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

Similar topics

3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
2
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
22
by: Ricky W. Hunt | last post by:
First, the subject probably doesn't use the correct terms but I'm not sure what it's called in VB. I'm writing a media player app. The subroutine that handles the "open file" button contains an...
7
by: Bonzo | last post by:
>From within a function, I want to pass a/some parameters to another function, AND all arguments, passed into this function. e.g. function firstFunction(){ //this function may have been...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
3
by: Ignacio Machin | last post by:
How can I call an event from another event: I want to call : DropDownList_SelectedIndexChanged in: Page_Load
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.