471,310 Members | 982 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Do I need to include this project?

How can I communicate with a parent form if that parent form type isn't
included in the project?

my.EXE project references a.DLL. a.DLL has a couple of forms that
my.exe uses. When my.exe opens a form in a.DLL, users can edit data in
that form. This data came out of a DataGrid on my.exe, which in turn
came from master.db. On the form in a.DLL, the user edits the data
and clicks update. A method in a.DLL saves to the DB. Now I need to
refresh the DataGrid in my.exe. What is the best way to do that?

Normally, I could cast the sender from a.DLL and refresh the grid in
my.exe. I can't do that here because my.exe isn't referencing a.DLL.
I'd like to keep a.DLL very generic, which means not including my.exe
as a reference, since the form in a.DLL can be called by any
application.

Any suggestions?

Thanks,
Brett

Jan 13 '06 #1
6 1078
Brett,

What you should do is define an interface in c.dll (another dll
basically) which the forms in a.dll implement. Then, you can cast the forms
to that interface, since both a.dll and the exe can reference c.dll (with
the interface in it).

The interface would expose a method that the form in the exe can
subscribe to, which would tell it to notify itself.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
How can I communicate with a parent form if that parent form type isn't
included in the project?

my.EXE project references a.DLL. a.DLL has a couple of forms that
my.exe uses. When my.exe opens a form in a.DLL, users can edit data in
that form. This data came out of a DataGrid on my.exe, which in turn
came from master.db. On the form in a.DLL, the user edits the data
and clicks update. A method in a.DLL saves to the DB. Now I need to
refresh the DataGrid in my.exe. What is the best way to do that?

Normally, I could cast the sender from a.DLL and refresh the grid in
my.exe. I can't do that here because my.exe isn't referencing a.DLL.
I'd like to keep a.DLL very generic, which means not including my.exe
as a reference, since the form in a.DLL can be called by any
application.

Any suggestions?

Thanks,
Brett

Jan 13 '06 #2
That would mean in a.dll, the form I pass in will be of type c
(interface). From there, I should be able to reference the form,
assuming it is a property of the interface. For example:

c.Form1

The property defines Form1 as a type of myexe.Form1. Or do I need an
interface for each form? Why do you say I need to cast?

Thanks,
Brett

Jan 13 '06 #3
Brett,

I am saying go the other way. When the EXE creates the form in a.dll,
have it cast the instance of the form created to your interface, and then
subscribe to the event exposed by it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11********************@g43g2000cwa.googlegrou ps.com...
That would mean in a.dll, the form I pass in will be of type c
(interface). From there, I should be able to reference the form,
assuming it is a property of the interface. For example:

c.Form1

The property defines Form1 as a type of myexe.Form1. Or do I need an
interface for each form? Why do you say I need to cast?

Thanks,
Brett

Jan 13 '06 #4
Ok. Maybe I don't fully see it because I don't understand this part:

The interface would expose a method that the form in the exe can
subscribe to, which would tell it to notify itself.

Let's say the exposed event is the close button click in c.dll. Would
it look something similar to this:

[my.exe form1]
private I_cdll_interface someFormIn_ADLL;
this.someevent += new
someFormIn_ADLL.btnCloseEvent(this.Handlesomevent) ;

What event would I use in my.exe to and listen and take action? Where
would it be defined?

Thanks,
Brett

Jan 13 '06 #5
Brett Romero wrote:
Ok. Maybe I don't fully see it because I don't understand this part:

The interface would expose a method that the form in the exe can
subscribe to, which would tell it to notify itself.

Let's say the exposed event is the close button click in c.dll. Would
it look something similar to this:

[my.exe form1]
private I_cdll_interface someFormIn_ADLL;
this.someevent += new
someFormIn_ADLL.btnCloseEvent(this.Handlesomevent) ;
No - that would be subscribing to an event within the form in the EXE.
What event would I use in my.exe to and listen and take action? Where
would it be defined?


The event would be *declared* in the interface in the DLL. It would be
*implemented* by the forms in the DLL (and possibly by the forms in the
EXE, if you wanted). It would be *used* by the forms in the EXE, which
would then subscribe to the events using handlers which would probably
be in the EXE.

To change your example:

private I_cdll_interface someFormIn_ADLL = ...;

someFormIn_ADLL.someevent += new
someFormIn_ADLL.btnCloseEvent(this.Handlesomevent) ;

Jon

Jan 13 '06 #6
The problem here is that any other application that uses c.dll will
also need a.dll right? As more DLLs use the interface, that's more
DLLs the apps will have to drag around.

Brett

Jan 13 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alexandre MELARD | last post: by
15 posts views Thread by drdoubt | last post: by
18 posts views Thread by Tuckers | last post: by
7 posts views Thread by Timothy Shih | last post: by
13 posts views Thread by Brett Baisley | last post: by
4 posts views Thread by Anders Eriksson | last post: by
8 posts views Thread by Brett Romero | last post: by

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.