473,408 Members | 2,832 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,408 software developers and data experts.

Dialog access to callers controls

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
5 1199
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: deko | last post by:
What is the best way to get a Common Dialog in Access 2000 Standard Edition? Microsoft suggests this: Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA"...
3
by: Greg Horwood | last post by:
Dear Anyone, While most of you will laugh at the fundamental nature of my question, I am a bit stuck. I am a reasonable VC++ programmer trying to make the switch to C#. I am trying to create a...
10
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
1
by: Rob Doe | last post by:
Hello, I have a button on a form that brings up the dialog box you get when using Access's menu to do Insert/Object: RunCommand acCmdInsertObject I'd like to over-ride some default settings...
9
by: MariusI | last post by:
Consider the following class layout public class Order { public ProductOrder AddProductOrder(/* variables required to create a product order */) { /* Check if the product order can be added...
1
by: nish85 | last post by:
Hi, i have uploaded my sit to web server goddady.com i have a button to download dyanmically generated excel file.This button is ajax enabled.....When i am click on this button it will popup a...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
9
by: Gord | last post by:
In VB6, a custom dialog can be easily created by adding a new form, adding whatever controls you like, sizing it as you like, adding code and then just loading/unloading it whenever you like....
2
by: Gord | last post by:
Is it possible to get a table type grid to appear on a custom dialog form? Basically, get the same thing as when you open a table in Datasheet view and can edit the individual columns. I'd like to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...

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.