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

problem with modeless dialog

I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)

Can somebody please suggest a way to achieve this?
Thanks,
Sunil Kiran B.

Jul 27 '06 #1
8 5444
hi,
You could maybe use reflection to call the method in another process or
you could use a message system between the two ( i.e; MSMQ )

James Jenkins
http://www.tamarsolutions.co.uk
<pr*******@hotmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)

Can somebody please suggest a way to achieve this?
Thanks,
Sunil Kiran B.

Jul 27 '06 #2
cp
You should be able to attach a delegate to the modeless dialog and
create an event handler in your main form which will update the main
form when it closes.

cp

pr*******@hotmail.com wrote:
I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)

Can somebody please suggest a way to achieve this?
Thanks,
Sunil Kiran B.
Jul 27 '06 #3
cp
Apologies ... that came out a bit wrong.
When you close your modeless dialog, you can call the delegate function
which will hook back into your main form.

cp

cp wrote:
You should be able to attach a delegate to the modeless dialog and
create an event handler in your main form which will update the main
form when it closes.

cp

pr*******@hotmail.com wrote:
I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)

Can somebody please suggest a way to achieve this?
Thanks,
Sunil Kiran B.
Jul 27 '06 #4
You can pass a reference to an instance of (what you call) "Project A" into
the constructor of the other class and store it in a field of type "Project
A" in the called class. This provides your second "project" (class) instance
with a reference to the other class, and allows you to call methods on it.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"pr*******@hotmail.com" wrote:
I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)

Can somebody please suggest a way to achieve this?
Thanks,
Sunil Kiran B.

Jul 27 '06 #5

pr*******@hotmail.com wrote:
I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)
In your main form in project A:

ModelessDialog md = new ModelessDialog();
md.Closing += new CancelEventHandler(this.ModelessDialogClosing);
md.Show();

then:

private void ModelessDialogClosing(object sender, CancelEventArgs e)
{
ModelessDialog closingMd = (ModelessDialog)sender;
MainFormMethod(closingMd.ValueFromModelessDialog);
}

or something like that.

Jul 27 '06 #6
Hi Bruce,

Thanks for your response.

I will be fine with your code, but how can i get the reference of the
Main Form method(MainFormMethod(closingMd.ValueFromModelessD ialog);)
because there is no reference of Project A in Project B.
If i try to add the reference of Project A in Project B it wont allow
because it will be a cyclic reference.
Sunil Kiran B.

Bruce Wood wrote:
pr*******@hotmail.com wrote:
I am working on a windows forms application and have the following
requirement.

I have two projects in my application Project A and Project B. And
Project A has the reference of Project B. I need to display a modeless
dialog from the main form which is in Project A and the modeless dialog
to be raised is in Project B. After closing the modeless dialog i need
to pass a value from modeless dialog to the main form of Project A and
also i need to execute a method in the main form with that value.
(the problem is i can not able to create an object of the main form
because Project B has no reference of Project A)

In your main form in project A:

ModelessDialog md = new ModelessDialog();
md.Closing += new CancelEventHandler(this.ModelessDialogClosing);
md.Show();

then:

private void ModelessDialogClosing(object sender, CancelEventArgs e)
{
ModelessDialog closingMd = (ModelessDialog)sender;
MainFormMethod(closingMd.ValueFromModelessDialog);
}

or something like that.
Jul 28 '06 #7
pr*******@hotmail.com wrote:
I will be fine with your code, but how can i get the reference of the
Main Form method(MainFormMethod(closingMd.ValueFromModelessD ialog);)
because there is no reference of Project A in Project B.
If i try to add the reference of Project A in Project B it wont allow
because it will be a cyclic reference.
Sunil Kiran B.

In your main form in project A:

ModelessDialog md = new ModelessDialog();
md.Closing += new CancelEventHandler(this.ModelessDialogClosing);
md.Show();

then:

private void ModelessDialogClosing(object sender, CancelEventArgs e)
{
ModelessDialog closingMd = (ModelessDialog)sender;
MainFormMethod(closingMd.ValueFromModelessDialog);
}

or something like that.
All of the code I wrote should be in project A, in your main form
class. The modeless dialog will signal when it is closing via its
Closing event. Your main form will listen to that Closing event and run
*its own* ModelessDialogClosing method when that happens. There are no
changes / coding required in the modeless dialog itself.

Jul 28 '06 #8
Thanks Bruce. It is working fine.

SKB

Jul 29 '06 #9

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

Similar topics

1
by: Carmine | last post by:
I'm currently writing a small program that churns on a repetitive task while displaying a progress & cancel modeless dialog. I've been having problems due to threadlocking, and I was wondering if...
0
by: Andrew | last post by:
I get a Null Reference Exception if I close a modeless form (that is, a form displayed using Show()) when a selection is made from a ComboxBox. If the form is modal (displayed using ShowDialog())...
1
by: Bruno van Dooren | last post by:
Hi, i was finally able to get my modeless dialog box to work, but a new problem did arise. i have implemented the dialog box in a dll that is called by a command line application that is...
2
by: Legendary Pansy | last post by:
Hello, I'm trying to accomplish the impossible by trying to do something equivalent of this example found here http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as Starting with "Listing...
2
by: proit_123 | last post by:
I am working on a windows forms application and have the following requirement. · I need to display a modeless dialog from the main form. o This allows user to continue to work with the...
3
by: AboutJAV | last post by:
Hi, I created a child dialog to tell the user that there is a loading of data from the database. When the loading is done, the child dialog will close. The child dialog contains a custom control...
0
by: Ralstoj | last post by:
Hi I am programing in Autocad with VB Autodesk have not given users access to new note function in Autocad CIVIL3d API. I am trying to work round this by creating notes using the sendkey...
0
by: Sin Jeong-hun | last post by:
I've found that if a MessageBox (called by alert/confirm from Javascript) or a web page modeless dialog is popped up, I cannot call Navigate of the WebBrowser control. If I do, a COM exception...
1
by: BillE | last post by:
Is there a trick so I can use a modeless dialog box in a master/content webform? I can display the modeless dialog, but it vanishes when a new content page is loaded. I need it to stay visible...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.