これは本当にばかげた質問に聞こえるかもしれませんが、これに対する答えはわかりません。VB プロジェクトの「OnLoad」に次のコードがあり、正常に動作します。
Dim ServName = (From line In IO.File.ReadAllLines("c:\Testing\Servers.csv") _
Where line.Length > 0 _ Let Items = line.Split(","c) _ Select New With _ {.ServerRef = Items(0), _ .ServerName = Items(1), _ .ServerIP = Items(2) _ } _ ).ToList
For Each Server In ServName
Console.WriteLine("[{0} [{1}] [{2}]", _
Server.ServerRef, _
Server.ServerName, _
Server.ServerIP _
)
Next
Dim h As String
h = 0
For Each Server In ServName
ComboBox1.Items.Add(Server(h).ServerRef)
ComboBox2.Items.Add(Server(h).ServerName)
ComboBox3.Items.Add(Server(h).ServerIP)
h = h + 1
Next
しかし、ComboBox_SelectedIndexChanged セクションでやりたいことは、ComboBox1 から行った選択を取得し、ComboBox3 で対応する情報を取得することです。
例 (CSV ファイル内):
サーバー1、クラスター1、192.168.0.1
サーバー 2、クラスター 2、172.16.16.1
等
私がやりたいことは、Server1 を選択すると、3 列目の IP がテキスト ボックス (TextBox1) に入力されることです。現状では、ComboBox2 & ComboBox3 は、情報が正しく読み込まれていることを表示するだけです。これらは実際には使用されません。