473,467 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

events (forms)

Hello,
I want to invoke event in one form which will be sent to other form
(both forms has nothing in common) . Could someone plz refer me to good
example for doing it? Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Nov 29 '07 #1
10 1157
article here will help:
http://www.eggheadcafe.com/articles/20040229.asp
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"csharpula csharp" wrote:
Hello,
I want to invoke event in one form which will be sent to other form
(both forms has nothing in common) . Could someone plz refer me to good
example for doing it? Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Nov 29 '07 #2
On Nov 29, 12:06 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
article here will help:http://www.eggheadcafe.com/articles/20040229.asp
The recommendation of using the "sender" parameter for arbitrary data
seems like a bad idea to me. The sender parameter has a clearly
defined role: it should be the object raising the event. If the event
logically takes arguments (e.g. a message to display) that's what the
second parameter is for.

Jon
Nov 29 '07 #3

It is not helping in my case because I need a communication between 2
forms which are not in inheritence relatioship .Hoc can I change value
of one control basing on change that occured on other form? (no
inheritence between forms) Thank you!
*** Sent via Developersdex http://www.developersdex.com ***
Nov 29 '07 #4
On Nov 29, 4:02 pm, csharpula csharp <csharp...@yahoo.comwrote:
It is not helping in my case because I need a communication between 2
forms which are not in inheritence relatioship
That's irrelevant - why would they need to be in an inheritance
relationship?

One form just needs to publish an event, and the other form needs to
know about the first form.

Jon
Nov 29 '07 #5
You are correct, it should be sent in a custom EventArgs - derived class. Old
article.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"Jon Skeet [C# MVP]" wrote:
On Nov 29, 12:06 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
article here will help:http://www.eggheadcafe.com/articles/20040229.asp

The recommendation of using the "sender" parameter for arbitrary data
seems like a bad idea to me. The sender parameter has a clearly
defined role: it should be the object raising the event. If the event
logically takes arguments (e.g. a message to display) that's what the
second parameter is for.

Jon
Nov 29 '07 #6


The question is how form2 will know about the event if it has no istance
of form 1? (which published it) I am just looking for an example of
event invoking in such case.If someone can send me a link of such
example that will really help. Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Nov 29 '07 #7
You are right, delegates are useless in WinForms event invoking.

Your forms should implement common interface and use it like

foreach (Form o in this.MdiParent.MdiChildren)

((IMyEvents)o).MyEvent();

Andrus.

"csharpula csharp" <cs*******@yahoo.comkirjutas sõnumis
news:%2****************@TK2MSFTNGP04.phx.gbl...
>

The question is how form2 will know about the event if it has no istance
of form 1? (which published it) I am just looking for an example of
event invoking in such case.If someone can send me a link of such
example that will really help. Thank you!

*** Sent via Developersdex http://www.developersdex.com ***

Nov 29 '07 #8
csharpula csharp <cs*******@yahoo.comwrote:
The question is how form2 will know about the event if it has no istance
of form 1? (which published it)
Well it will clearly need to know about the instance of form1 in some
way or other, but that has very little to do with inheritance.

You could pass a reference to form1 to the constructor of form2, or
something similar.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Nov 29 '07 #9
Andrus <ko********@hot.eewrote:
You are right, delegates are useless in WinForms event invoking.
Eh? What on earth do you mean by that? Delegates are the whole basis of
events in .NET, including WinForms events.
Your forms should implement common interface and use it like

foreach (Form o in this.MdiParent.MdiChildren)

((IMyEvents)o).MyEvent();
Well, at that point it's not really an event in .NET terms - it's just
a plain method.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Nov 29 '07 #10
bob
On Thu, 29 Nov 2007 01:54:15 -0800, csharpula csharp
<cs*******@yahoo.comwrote:
>Hello,
I want to invoke event in one form which will be sent to other form
(both forms has nothing in common) . Could someone plz refer me to good
example for doing it? Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Hi,
Check out my example in reply to your 'Design GUI' question on 28th
Nov.
regards
Bob
Nov 29 '07 #11

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

Similar topics

10
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading....
0
by: Mike Burkhart | last post by:
I have written the following class to build a data grid textbox column that has the KeyUp and KeyPress events defined for the TextBox. I also defined the KeyDown event for testing purposes only. ...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
by: Crucifix | last post by:
Hello, I'm writing a small C# app, and part of what I'm trying to do involves the dragging of PictureBox controls on a form. Unfortunately, MouseMove seems to be behaving very oddly, causing...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
3
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
3
by: Michael Tissington | last post by:
I'm confused by documentation and examples on using Delegate to create Events for use with COM In some situation I see a parameter list of (sender as Object, e as EventArgs) and other times I...
1
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
0
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
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:
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
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.