01.
private
void
comboBox1_SelectedIndexChanged(
object
sender, EventArgs e)
02.
{
03.
if
(
this
.comboBox1.SelectedIndex < 0)
return
;
04.
05.
double
result;
06.
07.
if
(
double
.TryParse(
this
.textBox1.Text,
out
result))
08.
{
09.
double
percent = 0.0;
10.
11.
switch
(
this
.comboBox1.SelectedIndex)
12.
{
13.
case
0 :
14.
percent = 0.2;
15.
break
;
16.
case
1 :
17.
percent = 0.3;
18.
break
;
19.
case
2 :
20.
percent = 0.5;
21.
break
;
22.
}
23.
24.
this
.BeginInvoke((MethodInvoker)
delegate
{
25.
this
.comboBox1.Text =
string
.Format(
"{0} = {1}"
,
this
.comboBox1.Text, (result * percent).ToString(
"N2"
));
26.
});
27.
}
28.
}