【发布时间】:2011-12-18 10:02:54
【问题描述】:
我正在尝试在我的应用程序中创建收藏夹,我需要在 ListBox 中显示一个包含收藏夹名称的表单。 选择一个名称并单击“选择”按钮时,我要将名称和URL放在不同的文本框中,这是我的代码任何想法。
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();
}
【问题讨论】:
标签: c# winforms dictionary listbox key