0

I am working on a unit converting project. The idea is to develop something like google's converter, except it is in windows application form. I want the result to show based on user's input at the moment. that means if user is converting 100cm to m, the result will show 0.01m when 1 is typed in and 1m as he completes the input. Is there a way to doing it? I have been searching in google but all of the helps are on java script. Thanks!

4

2 回答 2

5

You're looking for the KeyUp event.

于 2013-07-11T14:50:24.647 回答
0

使用 textchanged 事件。在此示例中,textbox1 为 cm,textbox2 为 m:

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0)
                textBox2.Text = "0";
            else
                textBox2.Text = (double.Parse(textBox1.Text) / 100).ToString();
        }
于 2013-07-11T15:01:16.350 回答