I have created a button on a form for which I set a return value programatically, seen below. First, is the event handler psudocode, followed by where the dialog result is returned to.
There is a default property where one can set a button's return behavior in the user interface, i.e. the Dialog Result behavior. In my full code I cannot see anywhere this button's return is set or modified.
When testing (running in debug mode) the first time the buttonSaveSet_Click event handler is used during the execution of code the returned dialog result value is "Cancel" despite the fact that I clicked the "Set" button. However, the second time that I execute the function, by pressing the same button, the dialog result is returned as "Yes".
It seems like there is another place that the Dialog Result is being modified, and I am setting that value in the incorrect location.
psudo code
private void buttonSaveSet_Click( object sender , EventArgs e )
{
setChars = new setChars();
//set the dr to yes.
buttonSaveSet.DialogResult = DialogResult.Yes;
// set the charCount
// set the rowCount
if ( conditional statement is true )
{
//return values;
}
else
{
//return nothing;
}
Close();
}
return location:
try
{
DialogResult dResult = setValPopup.ShowDialog();
SetChars sc = setValPopup.setChars;
int max;
if ( dResult == DialogResult.Yes )
{
if ( sc.set == true )
{
//do other work
}
}
}