473,666 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some Quick Questions

A few quick questions if possible.

1 - If I have a "List<..myL ist" 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.DataSo urce = null;
ListBox1.DataSo urce = 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 1278
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(f or
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.Componen tModel.BindingL ist<T>
System.Componen tModel.IBinding ListView
System.Data.Dat aView
System.Data.Rel atedView
System.Windows. Forms.BindingSo urce
System.Data.Dat aViewManager

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...@g mail.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
2071
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 correctly), the implication goes the other way. Do you find this a nuisance? Peace, EJ
1
1528
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( "name" ) Response.Cookies( "quoteform" )( "organization" ) = Session( "organization" ) Response.Cookies( "quoteform" )( "address1" ) = Session( "address" ) Response.Cookies( "quoteform" )( "address2" ) = Session( "suite" ) Response.Cookies(...
0
997
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 invoked, right? In other words, it is a serial, step-by-step pipeline, not one that ever works in parallel a la classic reader-writer processes sharing a buffer.
8
5371
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 is used by the user 2- check if a link to my application is there 3- if so, obtain the path (ANY PATH) to the quick-launch-folder from existing button(s)
7
3540
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 hours/minutes it represents so: $ convertmin Enter a number of minutes: 128
34
5037
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 companies current project. I have been able to setup postgresql in my rh box and
55
2706
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
2575
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
5441
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 the standard deviation (without duplicating code) 4) How to do all of this without duplicating the code for each String.
0
8444
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
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
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...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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();...
0
4198
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2771
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
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.