Re: problem with modeless dialog

Tech-Archive recommends: Fix windows errors by optimizing your registry




proit_123@xxxxxxxxxxx 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.

.



Relevant Pages

  • Re: dialogs Form.FormClosed is not run
    ... only modeless dialogs are difficult. ... It's true that because of the way a modal dialog is used, the code almost always instantiates it within the same block of code that will display it, but there's no requirement that you do so. ... In the cases where some other code needs to interact with the form, it is almost always the case that I'm dealing with a different class that I can just pass the form reference to for it to keep track of as long as it needs to. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: problem with modeless dialog
    ... I will be fine with your code, but how can i get the reference of the ... Project A has the reference of Project B. I need to display a modeless ... also i need to execute a method in the main form with that value. ... ModelessDialog closingMd = sender; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: problem with modeless dialog
    ... you could use a message system between the two (i.e; MSMQ) ... Project A has the reference of Project B. I need to display a modeless ... because Project B has no reference of Project A) ...
    (microsoft.public.dotnet.languages.csharp)
  • problem with modeless dialog
    ... I am working on a windows forms application and have the following ... Project A has the reference of Project B. I need to display a modeless ... because Project B has no reference of Project A) ... Sunil Kiran B. ...
    (microsoft.public.dotnet.languages.csharp)