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

Some Quick Questions

A few quick questions if possible.

1 - If I have a "List<..myList" and set it as a datasouce for say
ListBox1, then change items in "myList" is the correct/only way to
update the ListBox with the following?

ListBox1.DataSource = null;
ListBox1.DataSource = myList;

2 - BindingList<...is the same as List<...except when it is set as
a datasource then it auto updates the ListBox on changes (One Way
Only) basically? Should I pretty much always be using
BindingList<...if its being used as a datasouce and items are
changing? Is there an easy way to search MSDN for all Data Storage
Types that AutoUpdate when bound to a DataSource or is this basically
the only one?

3 - When Using the foreach enumeration I always seem to run into
"collection can't change" exception, and then forced to copy the
elements I want using the "CopyTo(..)" (of if I'm lucky and the
collection has it - ToArray()), or just use the simple
"for(...)" (Which is what I usally do since I don't like using up the
extra memory with the copy/toarray). Basically wondering if I am
doing this the right way or is there something else that the
getEnumeration makers put in place for me in these situations.
Thanks. I know these are probably really basic questions but I run
into them so often and just want to make sure I'm doing it the best
way I can.
Jan 15 '08 #1
4 1265
1: Well, if there is a BindingSource in the mix you could call
ResetBindings(), but otherwise yes

2: Anything that provides an IBindingList implementation with support
for notifications (ListChanged) will suffice. BindingList<T(for
classes) and DataView (for DataTables) are the most common two, but
you can write your own from scratch etc (if you feel so inclined). You
can also subclass BindingList<Tto fill in the blanks (sorting
support, etc).

3: What are you trying to do to the collection? List<T(but not
BindingList<T>) offers various delegate-based methods for removing
multiple items etc - but it is right: if the list contents change, the
enumerator will break. A standard for(int i ...) will suffice - but
again, it depends on what you want to do.

Marc
Jan 15 '08 #2
Is there an easy way to search MSDN for all Data Storage
Types that AutoUpdate when bound to a DataSource or is this basically
the only one?
Well, the hard part is knowing that IBindingList is responsible for
list updates... MSDN used to offer a "things that derive from this",
but not any more - so to explain how I (a few moments ago) checked
this: I fired up the free but excellent "Lutz Roeder's .NET
Reflector", searched for IBindingList and expanded Derived Types. This
revealed:

System.ComponentModel.BindingList<T>
System.ComponentModel.IBindingListView
System.Data.DataView
System.Data.RelatedView
System.Windows.Forms.BindingSource
System.Data.DataViewManager

So the only other thing (in the standard libraries) that offers this
is BindingSource, which is actually just an intermediary for working
with a concrete implementation (like BindingList<Tor DataView).

Marc
Jan 15 '08 #3
I fired up the free but excellent "Lutz Roeder's .NET Reflector"
Rather embarrasingly, I've just noticed that you can also get this
from the Object Browser in Visual Studio... and as such is probably a
better option for occasional use.

Marc
Jan 15 '08 #4
On Jan 15, 2:31*pm, Marc Gravell <marc.grav...@gmail.comwrote:
I fired up the free but excellent "Lutz Roeder's .NET Reflector"

Rather embarrasingly, I've just noticed that you can also get this
from the Object Browser in Visual Studio... and as such is probably a
better option for occasional use.

Marc
Thank you for the replys, they were helpful.

NB
Jan 15 '08 #5

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

Similar topics

7
by: Elaine Jackson | last post by:
Two quick newbie questions: 1) Does Python have passing-by-reference? 2) In ordinary parlance, "deep" implies "shallow" but not conversely. In the Python "copy" module (if I understand...
1
by: YT | last post by:
Couple of quick ASP (3.0) Cookie questions: 1/ I'm using a cookie in my asp script to place cookies (within a key) so my code looks like: Response.Cookies( "quoteform" )( "name" ) = Session(...
0
by: Stuart | last post by:
Hi, I am relatively new to Cocoon and have some quick questions as to how it processes its pipelines: 1. I assume that each stage in a pipeline must complete fully before the next phase is...
8
by: Dutchy | last post by:
Dear reader, In an attempt to obtain the path to the quick-launch-folder in order to create a shortcut to my application-updates during installation , I thought to: 1- check if quick launch...
7
by: kamkwokho | last post by:
Could any answer following questions as many as you can. ii) Write a C shell script convertmin which will read in a number, thought of as representing minutes, and print out the number of...
34
by: Karam Chand | last post by:
Hello I have been working with Access and MySQL for pretty long time. Very simple and able to perform their jobs. I dont need to start a flame anymore :) I have to work with PGSQL for my...
55
by: Steven Nagy | last post by:
Hi all, Sorry I have no time to test this myself.... Can I add the same attribute to a field twice? Eg. Public string myField;
0
by: netguru7575 | last post by:
All Quick Test Professional (QTP) FAQs QuickTest Professional (QTP) Questions and Answers Part # 1 http://softwareqatestings.com/content/view/188/38/
6
by: SuperDuper | last post by:
Just a few quick questions. 1) How would I count the length of words in 5 certain strings. SomeString.s1, SomeString.s2, etc.. 2) How to compute the average word length? 3) How to compute...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.