|
■No72834 (King さん) に返信
> 提示のコードだと FLG は SelectedIndexChanged イベントハンドラ内は
> スコープ外なのでビルドエラーになりますよね?
>
> やりたいことはこういうことですか?
>
> Private _isLoading As Boolean = False
>
> Private Sub FmA_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
> Try
> _isLoading = True
>
> With ComboBox1
> .Items.Add("魚料理")
> .Items.Add("肉料理")
> .DropDownStyle = ComboBoxStyle.DropDownList
> .SelectedIndex = 0
> End With
>
> With ComboBox2
> .Items.Add("ミディアム")
> .Items.Add("レア")
> .DropDownStyle = ComboBoxStyle.DropDownList
> .SelectedIndex = 0
> End With
> Finally
> _isLoading = False
> End Try
> End Sub
>
> Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
> If _isLoading Then
> Return
> End If
>
> If ComboBox1.SelectedIndex = 0 Then
> With ComboBox2
> .SelectedIndex = 0 ※
> .Enabled = True
> End With
> End If
>
> If ComboBox1.SelectedIndex = 1 Then
> With ComboBox2
> .SelectedIndex = 1
> .Enabled = False
> End With
> End If
> End Sub
返事が遅くなってすみません。
書いて貰ったコードで欲しい動きが出来ましたが、Hongliangさんが指摘した事を勘違いしていました。
現在は、下のコードを使用しています。
Hongliangさん、kingさん本当に有難うございます。
Public Class FmA
Private Sub FmA_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ComboBox2
.Items.Add("ミディアム")
.Items.Add("レア")
.DropDownStyle = ComboBoxStyle.DropDownList
.SelectedIndex = 0
End With
With ComboBox1
.Items.Add("魚料理")
.Items.Add("肉料理")
.DropDownStyle = ComboBoxStyle.DropDownList
.SelectedIndex = 0
End With
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex = 0 Then
With ComboBox2
.SelectedIndex = 0
.Enabled = True
End With
End If
If ComboBox1.SelectedIndex = 1 Then
With ComboBox2
.SelectedIndex = 1
.Enabled = False
End With
End If
End Sub
|