I have a Windows Mobile application in C#.
I have a couple of fields on the form, and when I hit enter I want the form submitted.Is there a way to mark a pushbutton as default?
Also how can I make so the Down key moves the focus into the nex开发者_开发问答t field? Tab-order is not respected?You can have a method that you link as the KeyDown event on all the controls from that form. In that you check if the KeyCode is Enter then you call the Submit method.
private void control_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter) Submit(); }
Same thing, in the KeyDown method you handle the DownArrow key. Im not sure if you have the System.Windows.Forms.Control.SelectNextControl() method in the Compact Framework, but if you don't have it you can easily build something like that by yourself.
精彩评论