473,497 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to use ListBox

Dear all,
I have a very simple question.
I have a listbox with datasource, where DataSource is an arraylist.
I.e. MyListbox.DataSource=MyDataSource.

Now I add/remove something to DataSource, i.e.
MyDataSource.Add("XXX")/MyDatasource.Remove("YYY")
I would expect that this XXX is shown in a Listbox/YYY deleted from a
listbox, but it is not the case.
How do force a ListBox to reread DataSource
Thanks ,
Boni
Nov 21 '05 #1
4 1573
Set the listbox datasource to Nothing and re-attach.

"Boni" <oilia@nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Dear all,
I have a very simple question.
I have a listbox with datasource, where DataSource is an arraylist.
I.e. MyListbox.DataSource=MyDataSource.

Now I add/remove something to DataSource, i.e.
MyDataSource.Add("XXX")/MyDatasource.Remove("YYY")
I would expect that this XXX is shown in a Listbox/YYY deleted from a
listbox, but it is not the case.
How do force a ListBox to reread DataSource
Thanks ,
Boni

Nov 21 '05 #2
"Boni" <oilia@nospam> schrieb:
How do force a ListBox to reread DataSource


\\\
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 #3
Dear Herfried,
What is CurrencyManager ? Is it arraylist?I can'find any refresh member in
listbox
DirectCast( _
Me.ListBox1.BindingContext(Me.ListBox1.DataSource) , _
CurrencyManager _
).Refresh()
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
"Boni" <oilia@nospam> schrieb:
What is CurrencyManager ? Is it arraylist?I can'find any refresh member in
listbox
DirectCast( _
Me.ListBox1.BindingContext(Me.ListBox1.DataSource) , _
CurrencyManager _
).Refresh()


'CurrencyManager' is a class which is part of the .NET Framework.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

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

Similar topics

17
3084
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
3
3586
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
8
2865
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
2
2900
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
2856
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
2253
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
7
4517
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
2269
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
1
4008
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
2828
by: Academia | last post by:
(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...
0
7120
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
6991
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
7160
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
7196
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...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.