0
我想在我的應用程序中做出最喜歡的,我需要顯示一個窗體,在列表框中有最喜歡的名稱。 當選擇一個名稱,然後單擊選擇按鈕,我想把名稱和Url放在不同的文本框中,這是我的代碼任何想法。ListBox從字典中插入,我需要得到的值和密鑰分開
private void EditFourites_Click(object sender, EventArgs e)
{
textBox1.Text = listBox1.SelectedItem.ToString();//put the selected value from the listbox to the textbox1 and this is my problem i want to make textbox1.text takes only the key of the listbox1.text
}
private void ListBox()
{
FavoriteXml FV = new FavoriteXml();//the favouritXml class is a class where i get the information about favourites
Dictionary<string, string> Favourite = FV.GetFavouriteCombo();//GetFavouriteCombo() will get the value as dictionary
listBox1.DataSource = new BindingSource(Favourite, null);
listBox1.ValueMember = "Value";
}
private void EditSpecificFavourite_Click(object sender, EventArgs e)
{
FavoriteXml FV = new FavoriteXml();
FV.EditFavourite(textBox1.Text.ToString(),textBox2.Text.ToString());//this is the EditFavourite where i want to change the specific favourite
ListBox();
}
好這項工作,並讓我選擇的價值,但我希望把重點過多的另一個文本 –
你是什麼意思的關鍵? listboxitem只能容納2個值,您可以看到的值和「SelectedValue」。 – fgblomqvist
我的意思是當我爲列表框綁定源時,我從字典中插入兩個值鍵和值在您的答案我只得到我想要的字典的鍵的值 –