473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox bound to a collection

I have a collection derived from CollectionBase. I am setting the DataSource
of my ListBox to the collection. That all works. I have two problems:

The code just after the call to InitializeComponent() looks like this:

shareListBox.DisplayMember = "Filename";
shareListBox.DataSource = shares;
shareListBox.ClearSelected();

'shares' is my collection.

1: When I set the DataSource, it immediately selects the first item. I don't
want anything selected by default. Calling ClearSelected() doesn't work, nor
does ListBox.SelectedItem = -1 (which I gather is what ClearSelected() does
anyway).

2: When I add an item to the 'shares' collection, how do I update the
ListBox?

I'm actually embarassed to ask the second question since I wrote a databound
grid custom control for a client, but for the life of me, I can't remember
how (if?) I handled that issue.

I know with DataSet, DataTable, etc, this is all handled via the
IBindingList and the CurrencyManager, but how is it handled with a
collection that doesn't implement IBindingList?

Thanks.

Pete
Nov 16 '05 #1
0 850

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

Similar topics

4
2977
by: Giulio | last post by:
Hello, I have a continuous form with a combo box inside. From the combo box I can pick some values which, by the "after-update" event, change some other combo box values determined by a query....
6
2858
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...
3
3825
by: David L Wright II | last post by:
I have a data bound listbox that I want to select multiple lines then process each line. I bound a two column datatable to the listbox and set the DisplayMember property to the appropriate column...
7
4518
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...
0
7188
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
7063
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
7258
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
7313
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
6970
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
5558
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,...
0
3156
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...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.