1. Create a New Application
2. Within this app, add a new item - a Form (so Form2.cs)
3. On Form2.cs add two buttons - wire up click events for both.
4. Form2 code will look like this:
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
5. On Form1, drop a Button on it and wire up the Click event.
6. Form1 code will look like this:
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.Closed += new EventHandler(f_Closed);
f.ShowDialog();
}
void f_Closed(object sender, EventArgs e)
{
using (Form2 f = sender as Form2)
{
MessageBox.Show(f.DialogResult.ToString());
}
}
7. Set Specific Page to Form1.wgx, save, compile, run.
Put breakpoints in both of the click events in Form2. When form1 is presented, click the button (Form2 will appear).
Then, click any of the buttons on Form2. You will hit a breakpoint and you can see that this.DialogResult = None.
But, when you return to Form1, the MessageBox says Cancel.
BUG: Somehow, WebGUI is modifying the DialogResult. I don't believe you should do that.
Here's how I found that and why:
Our main app has a tab control on it. Each tab gets a User Control added to it at run-time. The particular user-control has a DataGridView on it and some toolbars. From the toolbar I click the "Add new item" button which brings up a Maintenance Dialog. Typically, in the OK Click event (there's an OK button and a Cancel button), you will see code that looks like this:
if (!ValidateControlsOnThisMaintenanceForm())
{
return; // The Validate function actually pops up a MessageBox warning them of data entry errors.
}
WriteValidDataToDatabase();
this.DialogResult = DialogResult.OK;
this.Close();
In my testing, I just opened the Maintenance dialog, did nothing else (no typing in any of the textboxes, combos, etc), just clicked OK, and the form returned. It would usually warn me that field 1 was empty and that wasn't allowed.
I debugged the code and it got into our Validate code, I saw that MessageBox.Show was called, I saw that it returned before getting to the WriteValidDataToDatabase function and the this.Close call ...
but the Form actually closed. No MessageBox. It just closed. All of my Maintenance forms are now useless if they aren't going to work right. It should have never closed, this.Close() was never called. A MessageBox should have appeared.
I'm in the middle of trying to figure out the exact amount of code I need to add to a TestProject to duplicate this, I haven't yet, but I did just notice that WebGUI is changing None to Cancel so I posted it here. I'm sure you will get more, especially the major bug I'm trying to track down.
FYI, I've now tried two things since I made the switch to 6.4d (and I created a brand new VM for this, and made a copy of our code and built that using 6.4d):
a. To log-in
b. A random Maintenance Tab, popped open a maintenance dialog, clicked OK (expecting a MessageBox).
That's the only tests I've run and both failed. I don't think 6.4d is ready for prime-time.
EDIT:
And can someone tell me how to stop double-spacing while making this post? Look at the code that I typed isntead of cutting-and-pasting from somewhere else. It's all double-spaced for no reason. Also, what are the tags to make source code look like source code?