表示項目数を取得するには Items プロパティの Count プロパティを使用します。
下記は[表示項目数を取得]ボタンを押すと Count プロパティを使用して、現在表示されている項目数を取得する例です。
VBの例
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
'項目数を取得
Dim itemCnt As Integer = ComboBox1.Items.Count
MessageBox.Show("表示項目数は " & itemCnt.ToString() & " です")
End Sub
C#の例
private void button1_Click(object sender, RoutedEventArgs e)
{
// 項目数を取得
int itemCnt = comboBox1.Items.Count;
MessageBox.Show("表示項目数は" + itemCnt.ToString() + "です");
}
