M
mick
I`ll try to make this clear
I have a BindingList (progList) containing progItems.
class ProgItem
{
string name;
string path;
getters...setters here
overridden ToString() here
}
progList is bound to a ListBox and the "name" for each item is appearing
as it should.
I also have a textbox which will also diaplay the name of the particular item
that is selected in the Listbox. Next to the textbox is a button (Change). The idea
is, if I change the contents of the name textbox then press the Change button
the item.name will be changed to reflect this. Problem is, although the item name updates
the listbox does not.
private void btnChange_Click(object sender, EventArgs e)
{
// Find the selected item ***Thanks Pete***
ProgItem item = progList.Cast<ProgItem>().FirstOrDefault(delegate(ProgItem x)
{
return x.Name == lbxTabProgList.SelectedItem.ToString();
});
item.Name = tbTabProgListName.Text;
item.Path = tbTabProgListLocation.Text;
lbxTabProgList.Refresh(); //*** Tried this - doesnt work ***
lbxTabProgList.DataSource = null; // nulling then resetting the datasource does
lbxTabProgList.DataSource = progList; // work however
}
Dont think resetting the datasource is the right way so does anyone know why the listbox
update to what it`s bound to?
TIA,
mick

I have a BindingList (progList) containing progItems.
class ProgItem
{
string name;
string path;
getters...setters here
overridden ToString() here
}
progList is bound to a ListBox and the "name" for each item is appearing
as it should.
I also have a textbox which will also diaplay the name of the particular item
that is selected in the Listbox. Next to the textbox is a button (Change). The idea
is, if I change the contents of the name textbox then press the Change button
the item.name will be changed to reflect this. Problem is, although the item name updates
the listbox does not.
private void btnChange_Click(object sender, EventArgs e)
{
// Find the selected item ***Thanks Pete***
ProgItem item = progList.Cast<ProgItem>().FirstOrDefault(delegate(ProgItem x)
{
return x.Name == lbxTabProgList.SelectedItem.ToString();
});
item.Name = tbTabProgListName.Text;
item.Path = tbTabProgListLocation.Text;
lbxTabProgList.Refresh(); //*** Tried this - doesnt work ***
lbxTabProgList.DataSource = null; // nulling then resetting the datasource does
lbxTabProgList.DataSource = progList; // work however
}
Dont think resetting the datasource is the right way so does anyone know why the listbox
update to what it`s bound to?
TIA,
mick