I have a listbox that I have built in the following way:
foreach (dsoDataSet.MyDataTableRow dr in dsDataSet.MyTable.Rows )
lstDegree.Items.Add(new DegreeLst(dr.DegreeID, dr.Name));
lstDegree.DisplayMember = "DegreeName";
lstDegree.ValueMember = "DegreeID";
lstDegree.SelectedIndex = 0;
I have built a simple class to hold the DegreeID and the DegreeName (and description), so that I can keep track of the ID's underneath, while displaying a user friendly name to the user.
Unfortunately, the "DisplayMember" and "ValueMember" fields do not work unless the DataSource has been specified (is that correct?), so I have overridden the ToString() method of my class to return the "DegreeName".
This all works as expected, but I am having one small problem.
If I change the underlying string value of "DegreeName" like so:
((DegreeLst)lstDegree.SelectedItem).DegreeName = txtDegreeName.Text;
then the text in the ListBox does not update as expected, and I can't seem to find the method that will force a refresh of the text for the Items collection.
How do I force a ListBox to Re-Draw / Re-Process the Items in its List?