应用和代码
Private Sub PriceBox_Click(sender As Object, e As EventArgs) Handles PriceBox.Click
If CmbSize.SelectedIndex = 0 Then
PriceBox.Text = "£30"
ElseIf CmbSize.SelectedIndex = 1 Then
PriceBox.Text = "£40"
ElseIf CmbSize.SelectedIndex = 2 Then
PriceBox.Text = "£50"
End If
End Sub
此代码有效,但仅在单击时有效,选择组合框索引后,我需要使用它来自动更改
答案 0 :(得分:1)
如果只希望用户更改索引而不是程序更改,请使用
SelectionChangeCommitted
答案 1 :(得分:0)
您将需要处理CmbSize控件上的SelectedIndexChanged,如https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.combobox.selectedindexchanged?view=netframework-4.7.2
答案 2 :(得分:0)
组合框有SelectedIndexChanged-event,您可以使用:
Private Sub CmbSize_Changed(sender As Object, e As EventArgs) Handles CmbSize.SelectedIndexChanged
End Sub