473,386 Members | 1,715 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.

Updating a ListBox

I have a listbox that uses an ArrayList for a datasource. When I change
the information in the ArrayList, is there no way to "Refresh" the
listbox other than...?

Listbox.DataSource=Nothing
Listbox.DataSource=ArrayList
*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
3 1158
Terry,

I'm not in a position to try this code at the moment, but this might work:

Dim cm As CurrencyManager = Me.BindingContext(myArrayList)
cm.Refresh()

Kerry Moorman

"Terry Olsen" wrote:
I have a listbox that uses an ArrayList for a datasource. When I change
the information in the ArrayList, is there no way to "Refresh" the
listbox other than...?

Listbox.DataSource=Nothing
Listbox.DataSource=ArrayList
*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2
Hi Tel,

Try this,
arr.Insert(arr.count+1,"NewItem")
ListBox1.Items.Clear()
ListBox1.Items.AddRange(arr.ToArray)
HTH,

Phil

"Terry Olsen" <to******@hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
I have a listbox that uses an ArrayList for a datasource. When I change
the information in the ArrayList, is there no way to "Refresh" the
listbox other than...?

Listbox.DataSource=Nothing
Listbox.DataSource=ArrayList
*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #3
"Terry Olsen" <to******@hotmail.com> schrieb:
I have a listbox that uses an ArrayList for a datasource. When I change
the information in the ArrayList, is there no way to "Refresh" the
listbox other than...?


\\\
Private m_Data As New ArrayList

Private Sub Form1_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Load
m_Data.Add("Hello")
Me.ListBox1.DataSource = m_Data
End Sub

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
m_Data.Add("Bla")
DirectCast( _
Me.ListBox1.BindingContext(Me.ListBox1.DataSource) , _
CurrencyManager _
).Refresh()
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4

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

Similar topics

5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
2
by: Hey_Moe! | last post by:
I have subform which uses a SQL statement as the record source. One of the criteria (ie. Part of the WHERE condition) is a column value from a ListBox on the MainForm. Two problems exist: 1....
3
by: gdbjohnson-AT-yahoo-dot-ca-nospamplz | last post by:
I have a ListBox built of a simple custom object for the ListItems used to be able to hold a Data Value, and a Display Value, with accessors for each. I have overridden the ToString method to...
1
by: Claire | last post by:
As a Listbox.item, rather than using a string I'm using a ListItems object, overriding the ToString method When I add items to listbox.items, my strings are shown correctly. On the otherhand, when...
1
by: MrNobody | last post by:
Hi, I'm doing something where I add custom objects to a ListBox which have aToString() method overriden so it displays what I want. When adding instances of these custom objects to the ListBox I...
1
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
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
6
by: =?Utf-8?B?S2Fp?= | last post by:
Hi all, using AJAX Toolkit with vb.net 2.0 how could I make this "Updating..." Screen like e.g. on Codeplex when you click on the "Vote" button...
2
by: julie18881 | last post by:
I may be being really stupid here, i have spent the last 3 hours looking round your site and some other for answers to my problem, but have not had much luck (possibly cuase my brain just isn't...
3
by: Reg Verrin | last post by:
I have a program that displays constantly changing prices which it sources from the web once per second. The prices are displayed on a Listbox (not the best choice but there are good reasons for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.