我怎樣才能讓它在某處按下輸入鍵在我的表單上它會提交此代碼?使回車鍵像提交按鈕
我試過KeyPress事件等......但我似乎無法弄清楚。
private void
xTripSubmitButton_Click(object sender, EventArgs e) {
// Calculates the numbers from the input and output boxes/labels
Miles = double.Parse(this.xTripDestinationTextBox.Text);
Mpg = double.Parse(this.xTripMpgTextBox.Text);
Price = double.Parse(this.xTripPricepgTextBox.Text);
Output = Miles/Mpg;
Coutput = Output * Price;
//displays a message and the result for the numbers the user inputs
this.xTripOutputLabel.Text = "Total gallons you would use: " +
Output.ToString("0") +
Environment.NewLine + "Total amount it will cost you: " +
Coutput.ToString("C");
}
'ligtning bolt events' - Classic :) – Kelsey 2010-05-12 15:28:16
您正在問一個asp.net或winforms? – Elph 2010-05-12 15:29:51