WinForms AcceptButton not working?

前端 未结 5 463
生来不讨喜
生来不讨喜 2021-01-17 09:34

Ok, this is bugging me, and I just can\'t figure out what is wrong...

I have made two forms. First form just has a simple button on it, which opens the other as a di

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 09:59

    I had an issue with the AcceptButton not working and while the DialogResult suggestion was part of the fix, I had 2 other things that needed to change:

    1. My button was not visible - Intentionally because I wanted to stop the "ding" when a carriage return was "pressed" by scanning a barcode.
    2. The container that the button was inside made a difference. I had to have it in the same container, in my case a Forms.Panel, as the textbox that was trying to access it. I'm not sure why this would make a difference, but it did.

    I hope this helps someone.

提交回复
热议问题