By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

Dialog access to callers controls

P: n/a
I feel like a bonehead because this seems so easy.

I have 2 forms in the same namespace, Form1 and Form2.

Form1 is a MDI Container.
Form1 has a status bar : statusbar1
Form1 has a basic menu : File -> Show Dialog

Form2 is a form with a checkbox on it.

Form2 is shown via ...
WindowsApplication1.Form2 dialogForm2 = new Form2();

dialogForm2.ShowDialog();
All i want to do (for this examples sake) is when I click on the checkbox on
Form2 is update the statusbar1.Text on Form1.

This is easy enough when you don't want to show it as a dialog, and you just
set the Parent property of Form2 to Form1, but for whatever reason I can't
figure out how to do it when I want to show it as a dialog.
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You might consider exposing an event on Form2 that Form1 can hook and
receive notification of the checkbox change. Specifically, you would create
an event on Form2, then before Form1 calls the ShowDialog method of Form2
you hook into the created event, then you may send any information you want
through EventArgs to Form1, allowing Form1 to handle how the information is
displayed within itself. This way if you were to decide that the information
from Form2 needs to be shown to the user in a different place on Form1, you
don't need to make changes to code for the Form2 class. Thus, IMO, it
becomes more logical to maintain long term.

--
Tim Wilson
..Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:uB*************@tk2msftngp13.phx.gbl...
I feel like a bonehead because this seems so easy.

I have 2 forms in the same namespace, Form1 and Form2.

Form1 is a MDI Container.
Form1 has a status bar : statusbar1
Form1 has a basic menu : File -> Show Dialog

Form2 is a form with a checkbox on it.

Form2 is shown via ...
WindowsApplication1.Form2 dialogForm2 = new Form2();

dialogForm2.ShowDialog();
All i want to do (for this examples sake) is when I click on the checkbox on Form2 is update the statusbar1.Text on Form1.

This is easy enough when you don't want to show it as a dialog, and you just set the Parent property of Form2 to Form1, but for whatever reason I can't
figure out how to do it when I want to show it as a dialog.

Nov 16 '05 #2

P: n/a
How about in this situation, which is the situation I really need to use it
in.

I have a treeview on Form1, I create a new node in Form2 and need to add it
to the treeview on Form1. Would I do the same thing?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
You might consider exposing an event on Form2 that Form1 can hook and
receive notification of the checkbox change. Specifically, you would
create
an event on Form2, then before Form1 calls the ShowDialog method of Form2
you hook into the created event, then you may send any information you
want
through EventArgs to Form1, allowing Form1 to handle how the information
is
displayed within itself. This way if you were to decide that the
information
from Form2 needs to be shown to the user in a different place on Form1,
you
don't need to make changes to code for the Form2 class. Thus, IMO, it
becomes more logical to maintain long term.

--
Tim Wilson
.Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:uB*************@tk2msftngp13.phx.gbl...
I feel like a bonehead because this seems so easy.

I have 2 forms in the same namespace, Form1 and Form2.

Form1 is a MDI Container.
Form1 has a status bar : statusbar1
Form1 has a basic menu : File -> Show Dialog

Form2 is a form with a checkbox on it.

Form2 is shown via ...
WindowsApplication1.Form2 dialogForm2 = new Form2();

dialogForm2.ShowDialog();
All i want to do (for this examples sake) is when I click on the checkbox

on
Form2 is update the statusbar1.Text on Form1.

This is easy enough when you don't want to show it as a dialog, and you

just
set the Parent property of Form2 to Form1, but for whatever reason I
can't
figure out how to do it when I want to show it as a dialog.


Nov 16 '05 #3

P: n/a
Yep. Just create a custom EventArgs that contains the node to add, and then
in the event handler pull out the node and shove it in the treeview.

--
Tim Wilson
..Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
How about in this situation, which is the situation I really need to use it in.

I have a treeview on Form1, I create a new node in Form2 and need to add it to the treeview on Form1. Would I do the same thing?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
You might consider exposing an event on Form2 that Form1 can hook and
receive notification of the checkbox change. Specifically, you would
create
an event on Form2, then before Form1 calls the ShowDialog method of Form2 you hook into the created event, then you may send any information you
want
through EventArgs to Form1, allowing Form1 to handle how the information
is
displayed within itself. This way if you were to decide that the
information
from Form2 needs to be shown to the user in a different place on Form1,
you
don't need to make changes to code for the Form2 class. Thus, IMO, it
becomes more logical to maintain long term.

--
Tim Wilson
.Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:uB*************@tk2msftngp13.phx.gbl...
I feel like a bonehead because this seems so easy.

I have 2 forms in the same namespace, Form1 and Form2.

Form1 is a MDI Container.
Form1 has a status bar : statusbar1
Form1 has a basic menu : File -> Show Dialog

Form2 is a form with a checkbox on it.

Form2 is shown via ...
WindowsApplication1.Form2 dialogForm2 = new Form2();

dialogForm2.ShowDialog();
All i want to do (for this examples sake) is when I click on the
checkbox on
Form2 is update the statusbar1.Text on Form1.

This is easy enough when you don't want to show it as a dialog, and you

just
set the Parent property of Form2 to Form1, but for whatever reason I
can't
figure out how to do it when I want to show it as a dialog.



Nov 16 '05 #4

P: n/a
Cool.
Thx Tim!
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yep. Just create a custom EventArgs that contains the node to add, and
then
in the event handler pull out the node and shove it in the treeview.

--
Tim Wilson
.Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
How about in this situation, which is the situation I really need to use

it
in.

I have a treeview on Form1, I create a new node in Form2 and need to add

it
to the treeview on Form1. Would I do the same thing?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in
message
news:%2***************@TK2MSFTNGP15.phx.gbl...
> You might consider exposing an event on Form2 that Form1 can hook and
> receive notification of the checkbox change. Specifically, you would
> create
> an event on Form2, then before Form1 calls the ShowDialog method of Form2 > you hook into the created event, then you may send any information you
> want
> through EventArgs to Form1, allowing Form1 to handle how the
> information
> is
> displayed within itself. This way if you were to decide that the
> information
> from Form2 needs to be shown to the user in a different place on Form1,
> you
> don't need to make changes to code for the Form2 class. Thus, IMO, it
> becomes more logical to maintain long term.
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "Lucas Graf" <lg*******@comcast.net> wrote in message
> news:uB*************@tk2msftngp13.phx.gbl...
>> I feel like a bonehead because this seems so easy.
>>
>> I have 2 forms in the same namespace, Form1 and Form2.
>>
>> Form1 is a MDI Container.
>> Form1 has a status bar : statusbar1
>> Form1 has a basic menu : File -> Show Dialog
>>
>> Form2 is a form with a checkbox on it.
>>
>> Form2 is shown via ...
>> WindowsApplication1.Form2 dialogForm2 = new Form2();
>>
>> dialogForm2.ShowDialog();
>>
>>
>> All i want to do (for this examples sake) is when I click on the checkbox > on
>> Form2 is update the statusbar1.Text on Form1.
>>
>> This is easy enough when you don't want to show it as a dialog, and
>> you
> just
>> set the Parent property of Form2 to Form1, but for whatever reason I
>> can't
>> figure out how to do it when I want to show it as a dialog.
>>
>>
>
>



Nov 16 '05 #5

P: n/a
You're welcome.

--
Tim Wilson
..Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Cool.
Thx Tim!
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yep. Just create a custom EventArgs that contains the node to add, and
then
in the event handler pull out the node and shove it in the treeview.

--
Tim Wilson
.Net Compact Framework MVP

"Lucas Graf" <lg*******@comcast.net> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
How about in this situation, which is the situation I really need to use
it
in.

I have a treeview on Form1, I create a new node in Form2 and need to
add it
to the treeview on Form1. Would I do the same thing?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in
message
news:%2***************@TK2MSFTNGP15.phx.gbl...
> You might consider exposing an event on Form2 that Form1 can hook and
> receive notification of the checkbox change. Specifically, you would
> create
> an event on Form2, then before Form1 calls the ShowDialog method of

Form2
> you hook into the created event, then you may send any information

you > want
> through EventArgs to Form1, allowing Form1 to handle how the
> information
> is
> displayed within itself. This way if you were to decide that the
> information
> from Form2 needs to be shown to the user in a different place on Form1, > you
> don't need to make changes to code for the Form2 class. Thus, IMO, it
> becomes more logical to maintain long term.
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "Lucas Graf" <lg*******@comcast.net> wrote in message
> news:uB*************@tk2msftngp13.phx.gbl...
>> I feel like a bonehead because this seems so easy.
>>
>> I have 2 forms in the same namespace, Form1 and Form2.
>>
>> Form1 is a MDI Container.
>> Form1 has a status bar : statusbar1
>> Form1 has a basic menu : File -> Show Dialog
>>
>> Form2 is a form with a checkbox on it.
>>
>> Form2 is shown via ...
>> WindowsApplication1.Form2 dialogForm2 = new Form2();
>>
>> dialogForm2.ShowDialog();
>>
>>
>> All i want to do (for this examples sake) is when I click on the

checkbox
> on
>> Form2 is update the statusbar1.Text on Form1.
>>
>> This is easy enough when you don't want to show it as a dialog, and
>> you
> just
>> set the Parent property of Form2 to Form1, but for whatever reason I
>> can't
>> figure out how to do it when I want to show it as a dialog.
>>
>>
>
>



Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.