Dialog Result always gets reset to None after compiling

  • Thread starter Thread starter ~~~ .NET Ed ~~~
  • Start date Start date
N

~~~ .NET Ed ~~~

I am having a problem with my winforms. I had no problem with that in
VS.2005 but now on VS2005 it is showing some strange behaviour.

To simplify things my form has two buttons OK and Cancel. I set the
DialogResult properties of these buttons to OK and Cancel respectively.

Then at the form level I set the AcceptButton to the OK and assigned the
CancelButton to Cancel. So far so good. I save all the files recompile the
whole solution and all of a sudden the Form Accept/Cancel properties are
reset to NONE.

That explains why when I close my form and debug it even though I pressed OK
the ShowDialog() returns DialogResult.None but that is not what I have
specified with the design options

Is this a bug in VS.2005 ? I have the non-SP1 version (don't have that much
space left to install SP1 which refuses to install due to lack of space even
though I still have 2.0 GB).

Emilio
 
Ed,

To be honest, I've never even noticed the DialogResult property of a
button. Here is the code that I've always used.

public partial class DialogForm : Form
{
public DialogForm()
{
InitializeComponent();
}

private void buttonOK_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}

private void buttonCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
}

Jason Newell
Software Engineer
www.jasonnewell.net
 
That was the beauty of it, you place your buttons, to the buttons you assign
a DialogResult enumeration value and then at form level you specify which
buttons are your Accept & Cancel then you only need to check it after
ShowDialog().

Now however (.net 2.0 vs.2005) that is not working. Now I have to manually
set the dialog result like you did in your code, i.e. assign
this.DialogResult in the button click event but that is not how it used to
work.

I think this is a bug.

Emilio
 
Back
Top