"Items Collection Cannot Be Modified When The DataSource Property Is Set?
Jun 17, 2010
I have a combobobox on my form, and I use the following code to populate the data from SQL Server:
cbname.DataSource = DSAssetName.Tables(0)
cbname.DisplayMember = "IDWLNAME"
cbname.ValueMember = "FIDWID"
[code].....
View 2 Replies
ADVERTISEMENT
Apr 27, 2010
I am trying to refresh my combobox when an item is selected and added the highlighted code as shown below; [code]Items collection cannot be modified when the DataSource property is set.
View 3 Replies
Feb 13, 2010
I have two tables "Person" and "Alias" in a one to many relationship. I have a DGV for "Person" and want to use a combobox for the Aliases. I also have a textbox and a button for the user to type the alias name and click the button to add the alias name to the combobox and update the dataset. I keep getting the "Items collection cannot be modified when the DataSource property is set." Error. But if i use a DGV instead of a combobox for aliases, I have no errors and everything works fine. If I remove the datasource property for the combobox it will not get populated with the data already entered, so how, or can I, set it up where the combobox gets populated when the form loads and able to add items to the combobox????
View 1 Replies
Aug 26, 2011
Like i want it to read the lines i have in the text file but i get an error Each time i press the button Why?
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim objreader As New System.IO.StreamReader("C:UsersJamesDesktopMusicas.txt")
Do Until objreader.EndOfStream
[code]....
Error:
Quote:
Items collection cannot be modified when the DataSource property is set.
Error line
Quote:
ListBox1.Items.Add(objreader)
View 7 Replies
Sep 7, 2011
I have the following classes:
Product, Service and OrderItem
Product and Service must inherit OrderItem. So basically I want to store OrderItem object in my shopping cart and these object are store in a list.
Public MustInherit Class OrderItem
Private m_enuItemType As TypeOfItem = TypeOfItem.None
Private m_strUserID As Integer[code].....
View 1 Replies
Jun 19, 2009
I have several custom classes in a VB.NET (VS2008) project which are related to each other through generic list collections. The lower tier classes refer directly to some of the parent classes (to make it easier to refer backwards up the chain). My question is, is it possible to add the reference to the parent class when the item is added to a collection, when that collection is a property?
Below is some sampling of code to illustrate.
Public Class FlexServer
Private m_FlexLicenses As List(Of FlexLicense)
Private m_Modules As List(Of FlexModule)
Public Property FlexLicenses() As List(Of FlexLicense)
[code] .....
In the code above I have the FlexServer class which refers has two lists as properties, one for FlexLicense and one for Modules. The FlexLicense class has a property to refer back to the FlexServer class that "owns" it. In order to update this property in code, I have to add the FlexLicense to the FlexServer.FlexLicenses list AND set the FlexLicense.FlexServer property. What I am looking for is, is there a way (in the property definition or wherever) to both add the item to the list and alter it at the same time?
View 1 Replies
Dec 23, 2011
I get that error any time my form closes(Me.Close), even if I don't do anything to the form at all exept load another form like this: Form2.Show Me.Close().
View 8 Replies
Aug 4, 2011
We have some third party code that is causing some misery at the moment due to throwing the above error: it is slightly odd because it is an intermittent error. Here is the method that is causing the issue:
Private Shared Sub IntLocateDictionaries(ByVal haystack As ExpDictionary,
ByVal needlearray() As Object, _
ByVal resultarray() As Object, ByVal removemarks As Boolean)
Dim i As Integer
Dim item As Object
[Code] .....
I understand that this error is usually caused by trying to modify a collection whilst enumerating around it, hence why I've added logging on the only line that looks like might alter the collection... Since adding the logging we have still experienced the issue but NO LOGGING appears: this isn't surprising since if you look at the parameters on the calling line (the only place this Sub is called from) - removemarks is passed as False - this will be passed all the way down through the recursive calls and so that line which calls .Remove never gets executed....the fact we don't see logging proves this....
View 2 Replies
Feb 17, 2012
I am working on a project where I have a personnel class. The records stored in the class are populated a few records per second. At the time I am inserting the records, I have to check the same class to ensure the same record is not added twice. Since I am looping through the class using "For Each", I get a message "Collection was modified; enumeration operation may not execute".
View 5 Replies
Mar 11, 2009
i'm getting the following error: "COLLECTION WAS MODIFIED; ENUMERATION OPERATION MAY NOT EXECUTE."
The stack trace is ;
at System.Collections.SortedList.SortedListEnumerator.MoveNext()
at SatcomDiscoverySocket.clsGatewaySend.SendViaGatewaySend() in C:Documents and Settingsjim.SATCOM_DOMAINMy DocumentsVisual Studio 2005ProjectsSatcom Discovery Socket ServerSatcomDiscoverySocketSatcomDiscoverySocketThread PollingclsGatewaySend.vb:line 60
The line in question is but I don't believe that to be true I think its the line above it;GatewaySendEntry = Nothing The code is below. I can't figure out why, it's causing the error at that line and how to fix it.
[Code]...
View 17 Replies
Dec 21, 2011
I'm have a data management program. I've fixed everything in it, except when I run my Insert or update commands on a different computer I've installed it on, JIT tells me that the collection has be modified, it then gives me the option to continue or quit. I know it's been modified, the user knows it's been modified, how do I get rid of that?
View 10 Replies
Oct 15, 2009
I have this flood-fill algorithm, based on a queue (I tried the recursive method but pictures are too big and it was causing stack overflow).The problem is that when it makes the second pass in the for-each loop, the program crashes and compiler gives me the message "Collection was modified; enumeration operation may not execute.".Well, of course I know the collection was modified (it supposed to be!) since I am adding necessary items to it on-the-fly within the loop. What I cannot understand is why it happens since the for-each is based on the remaining items in the collection and not in a numeric index.
Below, the actual code:
Code:
Public Sub FloodFill(ByVal myx As Integer, ByVal myy As Integer)
Dim icoord As coordinate
Dim ocoord As coordinate
[code]....
View 2 Replies
Dec 29, 2011
This is what happened: on the form load of my application i created a background worker to bind collection (records from database filled in the dataset) on my control. but the problem is when the i updated the records on the database it throws an error if i run this procedure again.
If xControl.InvokeRequired Then
Dim MyDelegate As New InitializeDataBinding_Delegate(AddressOf InitializeDataBinding)
Invoke(MyDelegate, New Object() {xControl, xQuery, xPrimaryKey}) ' ERROR HERE SAYING: Collection was modified; enumeration operation may not execute.
[Code]...
View 2 Replies
Oct 27, 2011
I'm getting a Collection was modified; enumeration operation may not execute error every time I try to close this form. I suspect it has something to do with the StringBuilder() which I have declared in the starting form (Details1). I have already spent hours looking for the problem. It does not throw an error when I debug, only when I install on other machines.
[Code]...
View 1 Replies
Oct 15, 2011
I am encountering an error when looping through datarows. I searched SO and tried the solutions, but no luck. Collection was modified; enumeration operation might not execute.
Dim dRow As DataRow
For Each dRow In dt.Rows
dt.Rows.Add(dRow("CustNum"), dRow("SalesRepName"), dRow("mgrid"), "=""" & dRow("midValue") & """", dRow("dba"), dRow("sysDate"), dRow("statusID"))
Next
The error occurs the first time the code hits "Next". What would be causing Collection was modified; enumeration operation might not execute.How can I resolve this error?
View 2 Replies
Nov 28, 2010
I have a multithreaded app that is throwing the following error.Collection was modified; enumeration operation might not execute.[code]I'm pretty sure the collection is being modified by another thread. I attempted to fix the problem with the SyncLock's but clearly I'm missing something here.I thought I could lock the object by properly using SyncLocks, am I just not locking the right object(s)? Or am I completely missing something here.Besides using SyncLocks what other options do I have to prevent this error. I was thinking perhaps a global variable to keep track critical code sections so that no 2 threads enter.I'm also a little confused about what collection is being modified my first guess was CLResultsDataTable. ResultsDataTable, but I'm not sure.This is an older project I just recently picked back up so I'm still stepping through a lot of code to try to figure out how/why this is happening
View 3 Replies
Jan 10, 2011
I'd like some help with this error that other users has when they launch the app I created. I will copy / paste the error
Tittle: Collection was modified; enumeration operation may not execute.
Error:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
[code].....
View 10 Replies
Jul 27, 2007
I have looked at multiple posts regarding this issue, but can't seem to find a solution. To keep it simple I have an Access database with a single table. It does have a field as a primary key. When I click the save icon on the Binding Navigator I get this error having to do with the following code:
Me.Validate()
Me.TitlesBindingSource.EndEdit()
Me.TitlesTableAdapter.Update(Me.VFCurvesDataSet.Titles)
I cannot set the Refresh the Data Table check box in Advanced Options of the TableAdapter Configuration Wizard as it is grayed out. Once again, I have a primary key.
The posts I have reviewed indicate that an UpdateCommand needs to be created, but I can't understand how it should be done. W
View 13 Replies
Nov 11, 2005
I get an error when I try to edit a cell that already containts data. What am I missing? be as explicit as I am very new at this.
[Code]...
View 3 Replies
Apr 3, 2012
I have an Inherited Control with a Property that can be set in the designer. There's some code in the Set procedure to make sure it's set appropriately. However when I build or run the project that property is changed, I am assuming it's the sanity check code in the Set procedure that's causing it to be changed along with some VS beahviour. Here's the code:
[Code]...
View 8 Replies
Apr 6, 2012
currently in my application I have a Global Collection that is a Collection of Collections.Currently I am trying to add items/ elements to one of the child collections of the Global Collection but I am unable to use the collections methods of the child.When I assign a variable to the child collection and return the collection it is just an object with the collection inside.
Ex:
Dim GlobalCollection as New Collection
Dim ChildCollection1 as New Collection
Dim tempCurrentCollection[code]......
View 3 Replies
Apr 5, 2011
I have a 2 classes, one is Employee, the other is Employees. Basically Employees is a collection of Employee, I have a combo box where the Datasource is Employees.
When the user selects a value from the combo box, How do I get an Employee object from whatever is selected?[code...]
It is an Infragistics combo box by the way.
View 1 Replies
Apr 21, 2009
I have two combo boxesthat use the same collection for their datasource. The data member and value member are also the same properties. When the form loads, and I select an item in one of the combo boxes, the same item is then selected in the other combo box. I want the combo boxes to work separately. Do I need to have two different collections, even though they would have the same data in them?
cboInboardKnife.DataSource = cKnives
cboInboardKnife.DisplayMember =
"Name"
cboInboardKnife.ValueMember =
"ToolID"
cboOutboardKnife.DataSource = cKnives
cboOutboardKnife.DisplayMember =
"Name"
cboOutboardKnife.ValueMember =
"ToolID"
View 1 Replies
Aug 3, 2011
I have a custom collection which is derived from a base class implementing IEnumerable and IEnumerator, this collection is populated with custom objects.I'm trying to set the datasource on a ComboBox on a WinForm to use the above collection - but when the code is run the ComboBox is always empty.
The code I was using was this:
Private Sub ViewSources_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' declaration
Dim sourceCollection As SourceCollection
Dim source As Source
[code]....
View 6 Replies
Sep 7, 2010
I am customizing a DataGridView control. The DataGridView is supposed to be bound to a collection of some type (be it a List(Of T) or ArrayList or whatever), and the idea is that one can easily determine (at design-time in this case) which properties of the type have to be shown in the grid and which column header name they should get. One can do this using an attribute. For example, if I have a class Person with Name, Age and HairColor and I don't want to show the HairColor property, and want to show the Name property as 'Person', I would use:
vb.net
Public Class Person
<Grid.GridOptions(displayName:="Person", visible:=True)> _
Public Property Name As String
[code]....
I do this during run-time by simply looping through the properties of the bound type (in this case Person), retrieving the GridOptions attribute (if any) and checking the values provided. This works just fine except for one thing: I'm not really sure how to determine the type in the databound collection...
At the moment, I cast the DataSource property to an IList and retrieve the type of the first instance in that list (if any). If there isn't a first instance (the list is empty) then I don't know how to get the type... Often I know that it will be impossible to know the type. If someone is binding an ArrayList for example, then it's impossible to know what kind of items he's going to put in that ArrayList. Even the normal DataGridView cannot show any columns when databound to an empty ArrayList. However, the framework's DataGridView does show the columns when bound to, for example, an empty List(Of Person), or a Person array.
I'm pretty sure that casting the DataSource to an IList is not the correct way as all information about the type of items in that list is then lost. But I'm not sure what else to cast it to... ITypedList? IBindingList? I even considered List(Of T) because that's all I am going to be using, but besides the fact that the grid would then obviously only work for a List(Of T) I still don't know how to do this... I don't know 'T' so I can't cast it to a List(Of T)...
View 2 Replies
Aug 8, 2011
I've reviewed the links that were offered and don't find an answer. Neither has a lot of searching helped, probably because I can't think of a reasonably short way to ask the question. I hope that I've at least found the proper forum and category.
In my VB 2010 code, I've defined a structure that has about 30 elements. I want to sum the properties (they are all singles) of two members of the corresponding collection. I understand that I can do something like:
member1.property1=member2.property1+member 3.property1 for the entire set of properties of member2 and member3 to produce a completely defined member1 What I wonder is whether or not there is a way that uses fewer lines of code - I know that I can't do:member1=member2+member3, for example.
View 7 Replies
Sep 20, 2010
I'm getting this error when I deploy a VB.NET application and for the life of me I cannot figure out why.I do not get this error when I run the app from the IDE and the test machine I am deploying it to has a similar configuration to the dev machine...Windows 7 & .NET 3.51 SP1 and 4.0.The app bombs out when the main form is loaded after logging in. I've narrowed it down to the main form because if I load another form from login and then open the main form, this happens.
View 1 Replies
Apr 15, 2010
I realize this has been covered a million times before but with threading sometimes a problem is app specific. I have a multithreaded app that assigns a url to a thread which it then fetches and crawls. Now the function where I collect each threads items I have added synclocks assuming this would avoid alterations. But I get the "collection was modified, enumeration operation may not execute" error. look at my code:
For Each landingPage As String In landingPages
'logger.constructLog("Working on landingPage link: " & landingPage & " at " & DateTime.Now.ToString, True)
[Code]....
View 2 Replies
Dec 30, 2009
I have a form with a listview, and it operates as I expect it to, but when I close the form the debugger stops on the me.close() method and pulls up the collection was modified;enumeration operation may not execute error. this occurs even when I do nothing in the program and just try to run and close it.
View 8 Replies
Sep 16, 2011
When I close some of the forms I have opened in my project, i get an error that says "Collection was modified, Enumeration operation may not execute"I used a Try/Catch error handler on one of the forms and it stopped the error from popping up, but I want to know what I can do so that this does not keep happening.
View 6 Replies