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

Passing boolean value from one form to another form in C#

I'm working on a C# multi-form app in the compact framework. The forms are called from a main menu that stays in the background. Since there is no yes/no MeassageBox in the compact framework, I'm displaying a third form as a secondary check of the user's intentions. (i.e. Are you sure that you want to do this?)
I am trying to pass the boolean value back to the form that opens the secondary check form. Could someone please tell how this might be done?

Thanks in advance for any and all help.
Daniel

--
Message posted via http://www.dotnetmonster.com
Nov 16 '05 #1
3 3359
Hello Daniel,

I'd create a public property on the form and use it.
I'm working on a C# multi-form app in the compact framework. The forms
are called from a main menu that stays in the background. Since there
is no yes/no MeassageBox in the compact framework, I'm displaying a
third form as a secondary check of the user's intentions. (i.e. Are
you sure that you want to do this?) I am trying to pass the boolean
value back to the form that opens the secondary check form. Could
someone please tell how this might be done?

Thanks in advance for any and all help.
Daniel

Nov 16 '05 #2
If it is dialog you could also test the DialogResult var.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Daniel Passwater via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:25******************************@DotNetMonste r.com...
I'm working on a C# multi-form app in the compact framework. The forms are called from a main menu that stays in the background. Since there is no
yes/no MeassageBox in the compact framework, I'm displaying a third form as
a secondary check of the user's intentions. (i.e. Are you sure that you want
to do this?) I am trying to pass the boolean value back to the form that opens the secondary check form. Could someone please tell how this might be done?
Thanks in advance for any and all help.
Daniel

--
Message posted via http://www.dotnetmonster.com


Nov 16 '05 #3

"Daniel Passwater via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:25******************************@DotNetMonste r.com...
I'm working on a C# multi-form app in the compact framework. The forms are called from a main menu that stays in the background. Since there is no
yes/no MeassageBox in the compact framework, I'm displaying a third form as
a secondary check of the user's intentions. (i.e. Are you sure that you want
to do this?) I am trying to pass the boolean value back to the form that opens the secondary check form. Could someone please tell how this might be done?

Personally I never call ShowDialog form outside the form itself. (I think
it's a shame this method wasn't made protected).

I would use a pattern like this:

public class QuestionForm : Form
{
public bool Ask( Control owner, string question )
{
// Setup the form.
_questionLabel.Text = question;

// Show it.
switch( ShowDialog( owner ) )
{
case DialogResult.Yes:
return true;
default:
return false;
}
}
}

This way, the form can make sure it is set up correctly (ie you cannot
forget to set some message property before showing the form), and can accept
and return values in a more natural form (properties and dialog results
don't seem natural to me).

Stu

Thanks in advance for any and all help.
Daniel

--
Message posted via http://www.dotnetmonster.com

Nov 16 '05 #4

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

Similar topics

4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
5
by: Bernard Davis | last post by:
Hi, I need to pass the value held in a field in one form and have it appear in another form. I specifically don't want to have to refer to the original form name as it has passed, because I...
2
by: Mike P | last post by:
When you are passing a value to another page, and will need access to it throughout the page and on any postbacks, what is the best way to store it? By making it a variable accessible to the whole...
5
by: ferg96 | last post by:
I have a main form which displays various text etc depending on the file number eg, DA314, DA315. On the main form I have a button that opens up another form with a textbox in it. I want this text...
1
by: kunohiko | last post by:
Greets all... need help on reading value from another form under the same project. for example, i have frm1 and frm2, in frm2, i gotta use back the frm1.txtbox1.text value, how should i handle...
3
by: ou812vh | last post by:
I have a form with a subform. The subform gets populated with multiple records at any given time. I need to get the data from a particular field in the subform (which could be one record or more) to...
5
by: prasannagodbole67 | last post by:
IN c# : how to get value from another form .......................................... In 1st form there is a textBox that textbox value i want to another form in label.......
1
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hello Marc Gravell and Machin. Good Day. Why your not using an Instance in the form and yet your using a New Form? Im using it because I want to open a single form only. If Im using a New...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.