A
Academia
(If you've seen this in the drawing NG, sorry. I inadvertently sent it
there.)
I have a listbox populated with Objects.
The Class has a String field that ToString returns.
I assume that is what the ListBox uses for its display. Correct?
If I change the value of the object's string field the ListBox display does
not change. Would you expect it to change?
The Debugger shows that the item does in fact have the new value even though
the display has not changed.
I tried putting
ListBox1.SuspendLayout() and ListBox1.ResumeLayout() around the change code
to see it by chance that would trigger a change in display but it didn't. I
didn't really expect it would.
So I added code to remove and then add the item:
Dim j As Object = ListBox1.Items(ListBox1.SelectedIndex)
Dim i As Integer = ListBox1.SelectedIndex
ListBox1.Items.RemoveAt(i)
ListBox1.Items.Insert(i, j)
ListBox1.SelectedIndex = i
That works. Now as soon as the Object is changed the new value displays.
But I can't say I like it.
Isn't there a better way?
Thanks for any help
PS The ListBox appears to generate a list of strings so that it does not
have to access the objects when a Paint is required? Is that your
understanding?
there.)
I have a listbox populated with Objects.
The Class has a String field that ToString returns.
I assume that is what the ListBox uses for its display. Correct?
If I change the value of the object's string field the ListBox display does
not change. Would you expect it to change?
The Debugger shows that the item does in fact have the new value even though
the display has not changed.
I tried putting
ListBox1.SuspendLayout() and ListBox1.ResumeLayout() around the change code
to see it by chance that would trigger a change in display but it didn't. I
didn't really expect it would.
So I added code to remove and then add the item:
Dim j As Object = ListBox1.Items(ListBox1.SelectedIndex)
Dim i As Integer = ListBox1.SelectedIndex
ListBox1.Items.RemoveAt(i)
ListBox1.Items.Insert(i, j)
ListBox1.SelectedIndex = i
That works. Now as soon as the Object is changed the new value displays.
But I can't say I like it.
Isn't there a better way?
Thanks for any help
PS The ListBox appears to generate a list of strings so that it does not
have to access the objects when a Paint is required? Is that your
understanding?