问题描述
Hello CodeProject社区!
我的代码有问题。
当用户点击ComboBox控件中的相同项目时。
NumericUpDown值将重复计算。
当用户在ComboBox控件中选择相同的项目时,如何阻止计算?
我希望你们都可以帮助我,抱歉我的语法不好。
谢谢你。
我尝试过的事情:
为了更好地了解我当前的问题,下面是我的ComboBox控件代码
私人Sub ComboBox2_SelectedIndexChanged(sender As Object,e As EventArgs)处理ComboBox2.SelectedIndexChanged
'更改速度转换器单元
如果ComboBox2.SelectedItem =KB / s则
NumericUpDown2.DecimalPlaces = 0
NumericUpDown2.Increment = 1
TranferRateSpeedKBs.Enabled = True
TranferRateSpeedMBs.Enabled = False
'我的问题[如果用户在组合框中选择了相同的选项,我想阻止计算]
NumericUpDown2。 Value = NumericUpDown2.Value * 1000
ElseIf ComboBox2.SelectedItem =MB / s然后
NumericUpDown2.DecimalPlaces = 2
NumericUpDown2.Increment = 0.01
TranferRateSpeedKBs.Enabled = False
TranferRateSpeedMBs.Enabled = True
'我的问题[如果用户在组合框中选择了相同的选项,我想阻止计算]
NumericUpDown2.Value = NumericUpDown2.Value / 1000
结束如果
Hello CodeProject community!
I have a problem with my codes.
When user clicking the same item from ComboBox control.
The NumericUpDown value will repeat the calculation.
So how do I prevent the calculation when user choose the same item in ComboBox control?
I hope you all can help me and sorry for my bad grammar.
Thank you.
What I have tried:
For more understanding about my current problem, below is my code for the ComboBox control
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
'Change speed translator unit
If ComboBox2.SelectedItem = "KB/s" Then
NumericUpDown2.DecimalPlaces = 0
NumericUpDown2.Increment = 1
TranferRateSpeedKBs.Enabled = True
TranferRateSpeedMBs.Enabled = False
'My problem [I want to prevent the calculation if user has selected same option in combobox]
NumericUpDown2.Value = NumericUpDown2.Value * 1000
ElseIf ComboBox2.SelectedItem = "MB/s" Then
NumericUpDown2.DecimalPlaces = 2
NumericUpDown2.Increment = 0.01
TranferRateSpeedKBs.Enabled = False
TranferRateSpeedMBs.Enabled = True
'My problem [I want to prevent the calculation if user has selected same option in combobox]
NumericUpDown2.Value = NumericUpDown2.Value / 1000
End If
这篇关于如何在选择相同的东西时防止计算重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!