danielgr 0 Newbie Poster

Hi,

I wasn't sure where to post this, but thought it may save some time for someone who ran into the same problem.

I had a problem in a project, where whenever I clicked the "Accept" button on a form, it would close the form for no reason.

Originally, I thought it had something to do with forms being shown as .ShowDialog and changed it to a normal .Show
This had no effect.

I copied the form into a new project and continued to experience the same problem.

Eventually after going through the Designer.vb I found the problem, which is actually a bug with VS 2010. If you set a command button as the CancelButton of the form and then set another command button afterwards as the CancelButton, VS 2010 does not remove the following line of code from the first button:

Me.cmdAccept.DialogResult = System.Windows.Forms.DialogResult.Cancel

This will most likely happen if you are double-clicking through the options for the CancelButton.

As I mentioned, I'm not sure where the correct place to post this is, so I apologize in advance if this is not the correct place.