From: mick on 27 Jan 2010 08:04 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
From: mick on 27 Jan 2010 08:36 "mick" <coughcough(a)privacy.com> wrote in message news:uw%23xQF1nKHA.5508(a)TK2MSFTNGP02.phx.gbl... 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? Sorted it. Update() was the one I wanted. mick
From: mick on 27 Jan 2010 09:26 "mick" <coughcough(a)privacy.com> wrote in message news:eFMZDX1nKHA.6084(a)TK2MSFTNGP02.phx.gbl... "mick" <coughcough(a)privacy.com> wrote in message news:uw%23xQF1nKHA.5508(a)TK2MSFTNGP02.phx.gbl... <snip> > 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? >Sorted it. Update() was the one I wanted. It worked the first time but doesnt work now, so back to the problem. Anyone? mick
From: **Group User** on 27 Jan 2010 10:07 On Jan 27, 9:26 pm, "mick" <coughco...(a)privacy.com> wrote: > "mick" <coughco...(a)privacy.com> wrote in message > > news:eFMZDX1nKHA.6084(a)TK2MSFTNGP02.phx.gbl... > > "mick" <coughco...(a)privacy.com> wrote in message > > news:uw%23xQF1nKHA.5508(a)TK2MSFTNGP02.phx.gbl... > > <snip> > > > 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? > >Sorted it. Update() was the one I wanted. > > It worked the first time but doesnt work now, so back to the problem. > Anyone? > > mick You already tried it out 3 times. How about the fourth time and on ?
From: mick on 27 Jan 2010 10:38
"**Group User**" <imuaplease(a)gmail.com> wrote in message news:05cad4a2-50e4-4952-afca-0021fc04b1e1(a)l19g2000yqb.googlegroups.com... On Jan 27, 9:26 pm, "mick" <coughco...(a)privacy.com> wrote: > "mick" <coughco...(a)privacy.com> wrote in message > > news:eFMZDX1nKHA.6084(a)TK2MSFTNGP02.phx.gbl... > > "mick" <coughco...(a)privacy.com> wrote in message > > news:uw%23xQF1nKHA.5508(a)TK2MSFTNGP02.phx.gbl... > > <snip> > > > 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? > >Sorted it. Update() was the one I wanted. > > It worked the first time but doesnt work now, so back to the problem. > Anyone? > > mick >You already tried it out 3 times. How about the fourth time and on ? That helps, thanks. Now move along. mick |