473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Listbox repaint

After changing a property in an object added to a
listbox, how can I get the listbox to recall the ToString
method and display current values?

Example:
Private Sub AddToList
Dim MyObject as New MyClass
' Set property values
Lisbox.Items.Add(MyObject)
End Sub

Private Sub UpdateObject
Dim MyObject as MyClass=CType
(ListBox.SelectedItem,MyClass)
MyObject.Property="NewValue"
' Now, the object has new data
' but the old value from ToString still shows.
'What goes here to get the listbox to refresh/repaint?
End Sub

TIA
Nov 20 '05 #1
3 1910
Hi Randy,

The only way that seems to work is to reassign the list item to itself.

MyObject = ListBox1.SelectedItem
MyObject.Props = Foo
ListBox1.Items (ListBox1.SelectedIndex) = MyObject

Regards,
Fergus
Nov 20 '05 #2
* "Randy Riness" <an*******@discussions.microsoft.com> scripsit:
After changing a property in an object added to a
listbox, how can I get the listbox to recall the ToString
method and display current values?

Example:
Private Sub AddToList
Dim MyObject as New MyClass
' Set property values
Lisbox.Items.Add(MyObject)
End Sub

Private Sub UpdateObject
Dim MyObject as MyClass=CType
(ListBox.SelectedItem,MyClass)
MyObject.Property="NewValue"
Use 'DirectCast' instead of 'CType' here.

Try: 'ListBox1.Items(ListBox1.SelectedIndex) = MyObject'.
' Now, the object has new data
' but the old value from ToString still shows.
'What goes here to get the listbox to refresh/repaint?
End Sub


--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #3
Thanks - that works.
-----Original Message-----
Hi Randy,

The only way that seems to work is to reassign the list item to itself.
MyObject = ListBox1.SelectedItem
MyObject.Props = Foo
ListBox1.Items (ListBox1.SelectedIndex) = MyObject

Regards,
Fergus
.

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ike | last post by:
I changing the size of frames dynamically in a page (I am restricted in that I cannot perform a reload of the content of any of the frames). In MSIE, when I resize the frames, thinks repaint...
2
by: Joe A | last post by:
I'm using Access 2002 on Windows XP PC, 500 megs ram, Front end/back end app. I have a simple form that draws a thermometer to indicate progress of code that is running. The thermometer form...
4
by: Bob | last post by:
Trying to repaint a form named fcon using a new filter: 'Repaint the form with the new data Forms!fcon.FilterOn = False Forms!fcon.Filter = "RecNo = " & currecno & " AND Currentvalue = -1"...
3
by: jayderk | last post by:
Hello All, I am running in to a situation where the listbox is not refreshing for me. I am using a timer to cycle every second and call the timer_elapsed() event. in the time_elapsed event...
2
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: -------------------------------...
11
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to...
14
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
6
by: Zytan | last post by:
In win32 there was a way to 'turn off' a listbox from updating until you were done adding elements. Is there a way to do this in .NET? Zytan
0
by: milkay | last post by:
<I have code that uses 2 images> the program creates a window and then when u press play, it removes all components in the container. then, i add a NewPanel object. i add mouse listeners and all...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.