473,396 Members | 1,996 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,396 software developers and data experts.

LstBox DisplayMember Problem

I Have a ListBox that uses an ArrayList with objects as DataSource
The objects are added to the ArrayList using a Database
If I Add/Delete any item on the ListBox, the ArrayList is rebuilt with
something like:
MyArrList.Clear()
MyListBox.DataSource = nothing
...... peek database and ReFill MyArrList with MyObjects
If MyArrList.Count > 0 Then
MyListBox.DataSource = MyArrList
MyListBox.ValueMember = "SomeProperty1"
MyListBox.DisplayMember = "SomeProperty2"
MyListBox.SelectedIndex = 0
End If
Everything works fine if I Add or Delete any Item but the last one on
MyListBox
Debugging: When I delete the last Item the line:
"MyListBox.DisplayMember = "SomeProperty2" doesn't work and DisplayMember
remains = ""
and when I reach the line:
"MyListBox.SelectedIndex = 0" I get an error "Index was out of range"
(Obvious since DisplayMember is empty)
This only happens with the last item
What am I doing wrong?
This is the right way to change a ListBox DataSource (and it´s legal to do
it?)
Thanks
Marcos
Nov 19 '05 #1
1 2231
Hello,

"Marcos Ribeiro" <ki**@barretos.com.br> schrieb:
I Have a ListBox that uses an ArrayList with objects as
DataSource

[...]

Maybe somebody in this ng can help you:

news://news.microsoft.com/microsoft....ms.databinding

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #2

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

Similar topics

1
by: Irwin M. Fletcher | last post by:
ListBox DataSource DisplayMember Property Problems in C# I have a (single select) listbox with data and when I click on the list I can't get the right text selected. My listbox is setup...
0
by: Alpha | last post by:
Hi, I have a listbox with displaymember that I combined 3 columns together. After the user made the selection I then need to get each one the of the selected valuemember but then I don't want the...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
2
by: Sam | last post by:
This code does not work : With m_frmCtrl.cboMode .DataSource = m_dsCtrl.Tables(4) .ValueMember = "ModeID" .DisplayMember = "Description" .SelectedValue =...
0
by: frank | last post by:
Hello, I have a listbox which is bound to a datatable. I have set the displaymember and valuemember and all works well: the user dbl clicks an item in the list box, I use the valuemember to...
2
by: frank | last post by:
Hello All, I know this is a re-post, but I didn't get any bites on my last post. So here goes again: I have a listbox which is bound to a datatable. I have set the displaymember and valuemember...
0
by: Dundealing | last post by:
Hi, I have the following code to set the DataSource of a ComboBox to a certain table in an untyped DataSet, and I also want to set the DisplayMamaber of the ComboBox to a certain column: ...
6
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post by:
Hi I'm having problems getting the correct item to display in a bound combobox in my WinForms app. Using the following code: With Me.MyComboBox .ValueMember = "MyIdField" .DisplayMember =...
5
by: =?Utf-8?B?QmVu?= | last post by:
How would you add an item with its DisplayMember and ValueMember without binding to a datatable or dataview like: listbox.DisplayMember = "name"; listbox.ValueMember = "recid"; listbox.DataSource...
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: 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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.