Home All Groups Group Topic Archive Search About

VS 2005: Forms Designer Clears CancelButton and AcceptButton on Compile

Author
2 Oct 2006 6:42 PM
Josh Kodroff
I have a pretty standard Windows Form with 2 relevant buttons: btnOK
and btnCancel.  I set both buttons' DialogResult properties
appropriately.  I then set the form AcceptButton and CancelButton
properties appropriately.  However, whenever I click the Play button,
the 2 properties get reset back to their defaults (nothing).

Does anyone have any idea why this might be happening?  I'm
particularly annoyed because I got this right on another form and
cannot remember what I'm doing wrong.

Author
2 Oct 2006 8:13 PM
Oenone
Josh Kodroff wrote:
> Does anyone have any idea why this might be happening?

I followed through the steps just as you described on a form in VB2005, and
it didn't behave as you stated, the DialogResult properties were left
unchanged.

Are you finding that after you stop the project and examine the button
properties in the Properties window that they have both changed? Or are the
buttons just not behaving as you expect when you click on them?

--

(O)enone
Author
3 Oct 2006 6:14 PM
Josh Kodroff
Oenone wrote:
> Josh Kodroff wrote:
> > Does anyone have any idea why this might be happening?
>
> I followed through the steps just as you described on a form in VB2005, and
> it didn't behave as you stated, the DialogResult properties were left
> unchanged.
>
> Are you finding that after you stop the project and examine the button
> properties in the Properties window that they have both changed? Or are the
> buttons just not behaving as you expect when you click on them?
>

Visual Studio is literally changing the AcceptButton and CancelButton
properties from the values I selected to blank.  I've even tried
checking in the file to souce control, but to no avail.

My next idea is to manually write code for btnCancel that just sets the
DialogResult and hides the form, but I'm a little concerned that VS is
changing these settings without my say-so.

JK
Author
3 Oct 2006 10:37 PM
Josh Kodroff
To answer my own question, the issue was that I was using Form.Show and
not Form.ShowDialog from the calling form.  However, I am still
perplexed as to why VS was changing those properties on my behalf.

I'm not going to stay awake at night worrying about it, though.

Josh Kodroff wrote:
Show quoteHide quote
> Oenone wrote:
> > Josh Kodroff wrote:
> > > Does anyone have any idea why this might be happening?
> >
> > I followed through the steps just as you described on a form in VB2005, and
> > it didn't behave as you stated, the DialogResult properties were left
> > unchanged.
> >
> > Are you finding that after you stop the project and examine the button
> > properties in the Properties window that they have both changed? Or are the
> > buttons just not behaving as you expect when you click on them?
> >
>
> Visual Studio is literally changing the AcceptButton and CancelButton
> properties from the values I selected to blank.  I've even tried
> checking in the file to souce control, but to no avail.
>
> My next idea is to manually write code for btnCancel that just sets the
> DialogResult and hides the form, but I'm a little concerned that VS is
> changing these settings without my say-so.
>
> JK