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

Newbe DialogResult question

I am trying to work with 2 forms. If I set the ModalResult of a button on
the 2nd form it works OK. If I try to assign the result and then return it
does not return the value I set.

1st Form (calling form)

DeliveryInfo DeliveryFrm = new
DeliveryInfo(Convert.ToInt32(this.uniqueIDTextBox. Text));

DialogResult result;

result = DeliveryFrm.ShowDialog();

if (result == DialogResult.OK)
{
MessageBox.Show("Dialog Result was OK!");
}
else if (result == DialogResult.None)
{
MessageBox.Show("Dialog Result was None!");
}

2nt Form

private void deliveryInfoOkBtn_Click(object sender, EventArgs e)
{
try
{
// code to save dialog info here!

this.deliveryInfoOkBtn.DialogResult = DialogResult.OK;
this.Hide();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
Jan 12 '07 #1
1 2340
Thanks Mark.

Some times the most productive thing you can do is to get up from your desk
and walk down the hallway. I got so wrapped up in this I could not read the
code anymore.

All I needed was to use DeliveryInfo.ActiveForm.DialogResult =
DialogResult.OK; but I had a hard time getting there.

"Mark R. Dawson" <Ma*********@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
Hi Bill,
you need to set the DialogResult value on the form i.e. in your code
this.DialogResult = ... not on the button, by the time you set it on the
button it is too late because you are already in the click handler.

Hope that helps.

Mark.
--
http://www.markdawson.org
"Bill Cart" wrote:
>I am trying to work with 2 forms. If I set the ModalResult of a button on
the 2nd form it works OK. If I try to assign the result and then return
it
does not return the value I set.

1st Form (calling form)

DeliveryInfo DeliveryFrm = new
DeliveryInfo(Convert.ToInt32(this.uniqueIDTextBox .Text));

DialogResult result;

result = DeliveryFrm.ShowDialog();

if (result == DialogResult.OK)
{
MessageBox.Show("Dialog Result was OK!");
}
else if (result == DialogResult.None)
{
MessageBox.Show("Dialog Result was None!");
}

2nt Form

private void deliveryInfoOkBtn_Click(object sender, EventArgs e)
{
try
{
// code to save dialog info here!

this.deliveryInfoOkBtn.DialogResult = DialogResult.OK;
this.Hide();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}

Jan 12 '07 #2

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

Similar topics

9
by: Yaro | last post by:
Hello DB2/NT 8.1.3 Sorry for stupid questions. I am newbe in DB2. 1. How can I read *.sql script (with table and function definitions) into a database? Tool, command... 2. In Project Center...
5
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
2
by: steve bull | last post by:
I have built what I think should be a dialog box. It contains 4 tabbed panes for generating a range of colors. Each tabbed pane consists of a panel with all the widgets on them including the OK and...
1
by: Jim | last post by:
I have created a windows form that contains several tab pages which contain a panels. On a tab page I am trying to dynamically create a series of buttons in that pages panel. I am failing because...
7
by: Frank Maxey | last post by:
I am fairly new to VB.Net and am having a curious problem. I have an entry dialog form called from a main form. The calling form needs to check the DialogResult field for an OK response. In...
11
by: rk | last post by:
According to the docs, I would expect to check the result of an OpenFileDialog in a VS 2005 CLR Windows Forms application this way: if (openFileDialog1->ShowDialog()== DialogResult::OK) ...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
2
by: WP | last post by:
Hello, I making and Windows Forms program and I have a dialog with two buttons. I have set the DialogResult property for these buttons to DialogResult.OK and DialogResult.No, respectively (however,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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.