acceptbutton

C# Validate before leaving accept_button event

南笙酒味 提交于 2019-12-23 09:23:37
问题 Excuse me if this is a silly question but i'm a beginer here. I have a simply custom dialog with two buttons: Accept and Cancel. The Accept button is the acceptButton of the form. I want to do some validations on the Accept_Click event and decide if i can close the dialog or not, but everytime it leaves this method, the dialog automatically closes itself and returns Ok. What can I do to stop the dialog from closing itself? or i have to do things in some other way? thanks 回答1: I would have a

Press enter in textbox to and execute button command

跟風遠走 提交于 2019-12-20 08:49:17
问题 I want to execute the code behind my Search Button by pressing Enter . I have the Accept Button property to my search button. However, when i place my button as NOT visible my search doesn't execute. I want to be able to press Enter within my text box and execute my button while its not visible. Any suggestions would be great! Below is one attempt at my code in KeyDown Event if (e.KeyCode == Keys.Enter) { buttonSearch_Click((object)sender, (EventArgs)e); } 回答1: You could register to the