473,809 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IList being updated and telling bound controlls

I have implemented a container class with IList and bound it to a listbox.
Works just fine, but if i then add a new item to my list, the listbox is not
updated.

Looking at the definition for IList it is clear that it does not have any
events to tell the bound controlls about changes, but can it really be that
after adding to the list I allways have to call an update method for the
listbox? I would rather have designed the interface to allow bound controlls
to get an event and then do an update on their own.

As a side note.. I am doing the change from c++ to c#, so i would like to
add a very basic question which I cant find the answer to... how exactly
_do_ you update a listbox when the data changes? There are many update,
refresh and invalidates, but they all seem to relate to a repaint.. not a
re-load list.

Nov 15 '05 #1
1 2209
Jakob:

I believe a data source has to implement the IBindingList interface in
order for the control to automatically update.

If you have an IList source, you could just re-assign the DataSource
property of the bound control to the list and it will reload from
scratch. Of course, this can become expensive on big collections with
lots of changes, but I imagine that is why classes like the DataView
implement IBindingList.

HTH,

--
Scott
http://www.OdeToCode.com

On Tue, 27 Jan 2004 07:50:01 +0100, "Jakob Nielsen" <jn*@no.mail>
wrote:
I have implemented a container class with IList and bound it to a listbox.
Works just fine, but if i then add a new item to my list, the listbox is not
updated.

Looking at the definition for IList it is clear that it does not have any
events to tell the bound controlls about changes, but can it really be that
after adding to the list I allways have to call an update method for the
listbox? I would rather have designed the interface to allow bound controlls
to get an event and then do an update on their own.

As a side note.. I am doing the change from c++ to c#, so i would like to
add a very basic question which I cant find the answer to... how exactly
_do_ you update a listbox when the data changes? There are many update,
refresh and invalidates, but they all seem to relate to a repaint.. not a
re-load list.


Nov 15 '05 #2

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

Similar topics

2
1936
by: Darren | last post by:
I'm trying to bound a custom object to a combobox using DataSource property. The code works correctly however when the user selects a different value I get a runtime error of NullReferenceException - Object reference not set to an instance of an object. I've posted a snippet of the code below: I think it maybe something to do with CopyTo or SyncRoot as I don't understand what these are. Any please will be appreciated. Thanks, Darren.
4
2968
by: vulcaned | last post by:
Hi All, Hopefully I explain this well........ In Access97 I have a form which has a tab control on it, each tab has a sub-form which is bound to its appropriate table(I'll call them 'Detail' tables). I have a 'Header' table and fields from it are displayed on the form above the tab control. Header table name is tblClientInfo Detail tables are tblPolicyInfo, tblBeneInfo, tblRiderInfo
4
7300
by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving from an interface and only implementing some of it means something is wrong: either the interface specification is wrong e.g. not minimal or the derivation is wrong e.g. the type can't actually honour this contract.
2
5798
by: Matt | last post by:
Hello all, I have written a collection class that implements IList. The class currently uses an ArrayList for its internal storage. I am somewhat confused as to how I should implement the SyncRoot property on my class. The MSDN documentation seems quite evasive on the subject: For collections whose underlying store is not publicly available,
0
955
by: Darren | last post by:
I'm trying to bound a custom object to a combobox using DataSource property. The code works correctly however when the user selects a different value I get a runtime error of NullReferenceException - Object reference not set to an instance of an object. I've posted a snippet of the code below: I think it maybe something to do with CopyTo or SyncRoot as I don't understand what these are. Any please will be appreciated. Thanks, Darren.
5
13644
by: Lonifasiko | last post by:
I've got this in my code, that is, we're inside a class called Patient, so a Patient can have Appointments: private IList<Appointment> _appointments = null; public IList<Appointment> Appointments { get
1
1211
by: Brian Mitchell | last post by:
Hello, I am trying to update my listbox whenever I remove something from the underlying datasource (IList). I understand that you must use the SuspendBinding and ResumeBinding methods of the BindingContext to accomplish this but I think I am doing something wrong: Dim bc As BindingManagerBase = BindingContext(MyClass) bc.SuspendBinding() MyClass.Remove(ListBox1.SelectedItem) bc.ResumeBinding()
3
2925
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have a DataGridView bound to a database query result. I would like to pick an arbitrary column from the DataGridView and pass its data to a method that requires it to be an IList. What is the best way to do this?
4
13165
by: forest demon | last post by:
I have an IList/Collection that contains items in a ListView. If i click on an item in the ListView, i can capture the index (lv.SelectedItems.Index) and reference the correct item in the associated IList/Collection . Once I've sorted the ListView, obviously the indices do not match up anymore. So, should i sort the IList/Collection when I sort the ListView (which seems overkill to me) or some how sort the indices associated with the...
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10391
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4333
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 we have to send another system
2
3862
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.