HighTechTalks DotNet Forums  

I change the ListBox's item but the display does not change

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss I change the ListBox's item but the display does not change in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Academia
 
Posts: n/a

Default I change the ListBox's item but the display does not change - 11-02-2007 , 08:20 AM






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?













Reply With Quote
  #2  
Old   
Jeff Johnson
 
Posts: n/a

Default Re: I change the ListBox's item but the display does not change - 11-05-2007 , 04:08 PM






"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote


Quote:
I have a listbox populated with Objects.
I would recommend you repost your question to
microsoft.public.dotnet.framework.windowsforms.con trols. This group is
mainly about using GDI+ for drawing images, not dealing with how standard
controls draw/update themselves.




Reply With Quote
  #3  
Old   
Academia
 
Posts: n/a

Default Re: I change the ListBox's item but the display does not change - 11-06-2007 , 12:20 PM



Thanks, I did after I posted it here by mistake.

"Jeff Johnson" <i.get (AT) enough (DOT) spam> wrote

Quote:
"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OsLCbMVHIHA.4880 (AT) TK2MSFTNGP03 (DOT) phx.gbl...

I have a listbox populated with Objects.

I would recommend you repost your question to
microsoft.public.dotnet.framework.windowsforms.con trols. This group is
mainly about using GDI+ for drawing images, not dealing with how standard
controls draw/update themselves.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.