謝謝你不能只創建一個類?像這樣
class ips
{
public int ident;
public string ip;
public ips(int Ident, string Ip)
{
this.ident = Ident;
this.ip = Ip;
}
}
//fill the List
const int MAXELEMENTS = 512;
ips[] ipList = new ips[MAXELEMENTS];
ips ipa = new ips(1111, "10.10.10.1");
ips ipb = new ips(2222, "20.20.20.1");
然後激發SelectionChangeCommitted事件?
public Form1()
{
ipList[0] = ipa;
ipList[1] = ipb;
InitializeComponent();
cBox1.AutoCompleteMode = AutoCompleteMode.Append;
for(int i = 0; i < ipList.Count(); i++)
{
if(ipList[i] != null)
cBox1.Items.Add(ipList[i].ip);
}
}
private void cBox1_SelectionChangeCommitted(object sender, EventArgs e)
{
tBox1.Text = Convert.ToString(ipList[cBox1.SelectedIndex].ident);
}
我希望這有助於你
我不確定你在問什麼...你需要幫助解析文本?或者在文本框中使用自動完成功能? –
是的,在解析文本!我真的不知道如何管理_「查看關係列表並顯示與主機名相關的IP」_ – mfgarcia