C# - Find And Insert Into List Class Collection?
Mar 10, 2011I have class called GroupSelect and made a collection List(Of GroupSelect)().[code]...
View 1 RepliesI have class called GroupSelect and made a collection List(Of GroupSelect)().[code]...
View 1 RepliesI'm looking for a tutorial on how to Adding a list(of Class) or Collection as another Class's Property.What I am after is something like the Columns Collection for the DatagridView control.I would like to add Items in the graphics screen. Where the item list is displayed in the left panel and the selected Item properties are displayed in the right panel.
View 4 RepliesI seem to have problem with passing a collection/sorted list/ list of strings from one class to another.I am using property procedure to pass it, however nothing is sent to another class. There isn't any error messages either.[code]
View 3 RepliesHow to create collection class and add list of items to collection class that stores list of items?
View 3 RepliesI have class called GroupSelect and made a collection List(Of GroupSelect)().Now I need find to RowNo = 4 in List(Of GroupSelect)() and get GroupSelect object.[code]
View 2 RepliesI 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].....
[code]The reason that this is a problem is that this is a collection of EventBase objects, but I'm trying to populate it with child classes instead. For example, I might have a JumpEvent class that inherits EventBase, and this is being put into the EventBaseCollection. That means that value.GetType() returns the type of JumpEvent, which as you might guess does not equal the type of EventBase.The goal of course is to simply loop through all of the various events without having to know anything about the sub-classes. Is there a way to determine the type of the base class so that the OnValidate call will work? Or is this just the wrong way to go about it altogether?
View 2 Replieshow to insert records with dapper-dot-net. However, the answers, while informative, didn't seem to point me in the right direction. Here is the situation: moving data from SqlServer to MySql. Reading the records into an IEnumerable<WTUser> is easy, but I am just not getting something on the insert. First, the 'moving records code':
// moving data
Dim session As New Session(DataProvider.MSSql, "server", _
"database")
Dim resources As List(Of WTUser) = session.QueryReader(Of WTUser)("select * from tbl_resource")
[code]....
I have a collection of string items(approx 2000) and I need to find and list all the dupes in the list.How would I go about this?
View 8 RepliesI have created collection and adding values in the collection, later I need to find if uer passed value is exist in the collection or not, I use contains finction to find the answer but it always returns false even though user passed value exist in the collection list. here is my code:
[Code]...
I'm wondering, what happens when you do following:
Collection.Insert(55, "Input")
The collection contains 20 items, so 19 would be the last index. This doesn't work, I get the expected outofrangeException. But when I do :
Collection.Insert(20, "Input")
That works without a problem, even though it is 1 out of the collection.
The following code creates a Collection where every Item is assigned a value equal to the last item added. At the end of adding for example seven items all the entries are identical to the last one added, although each has the correct key
The parameter passed to the function - aCOA() - is a comma delimited string of three strings.
The code is as follows
Public Function myCOA(ByVal aCOA() As String)
Dim thisCOA As New Collection
Dim keyCOA As String
[Code]....
Is this a bug in the code or in the Collection Class. I have traced the operation of the code and all seems OK until the second entry is added at which time the first entry Item get the same value as the second entry Item and so on.
I have worked some with classes and collections in the past but seek some direction before I start on this project as to the best method to use.I will be reading 20,000 or so lines from a text file. partno, desc and loc Each will contain 3 elements to be collected and stored temporarily.There are 2 results that I desire that relates to selling of products
First Result: Sorted list of most used partno, desc
2,234 partno (most sold)
1,345 partno (2nd most popular)
etc.
2nd Result: Sorted list by specific loc., partno, desc
loc. 45 - 234ea partno, desc
loc. 45 - 143ea partno, desc
Maybe end up with the top 500 selling products in the list. This data will then be added to a dataviewgrid for printing and then deleted.So, to temporary store and sort should I use some type of collection or classes? I know how to fight my way to either but which would be the best method?
I want to be able to get an instance of a class based on two fields in that class. I was hoping to use something like a dictionary, because I thought indexing would be the best for performance. Should I just use LINQ or go back to a strongly typed dataset? Here's an example of what I'm trying to do[code]...
View 2 RepliesI have a base class (ex: Class1) containing a list of another base class (ex: ClassA). Each child class of first base class (ex: Class1AA, Class1AB,..) containing a list of child class of second base class (ex: ClassAA, ClassAB,...)The client must never know which child class is using, then i don't think i can use generic for my bases classes.I try something like this and many more, but i always received errors..Imports System.Collections.Generic
[code]...
I have some nested objects arranged like this:
Process
Persons
Workflows
Tasks
So you have one Process. Then multiple Persons can be added to and multiple WorkFlows can be added Process as well. Multiple Tasks can be added to each WorkFlow but I need a way to tie which Person is doing each task. I basically need a way that for each Person added to the Process it, in it's constructor, assigns a Person.ID property that can then be assigned into each Task's PersonID property...
Dim myProcess as New Process()
Dim myPerson as New Process.Person()
myProcess.AddPerson(myPerson)
[code]....
I converted a project from 2008 to 2010 to be able to use the TPL.I've updated the compile target to .NET 4. Everything seems good, including the .NET 4 specific TPL stuff...except that:[code]
View 7 RepliesThought I had got this sorted earlier but unfortunately not. A property in a class is a collection of objects.
[Code]...
I decided to go back to the VB6 book, "Learn to Program Visual Basic Objects", so I can code it in VB2010. This has been a great learning experience. However I've run into a problem. I'm getting an error with a For....Each loop for a collection class. The error message states, Expression is of type 'China.Order', which is not a collection type." From what I've deduced the problem deals with an enumerator. I could be wrong.
View 2 RepliesI'm working on a small project and got into some troubles trying to keep it OOP.I have a global variable:
Public Stations As New Microsoft.VisualBasic.Collection()
And 2 classess: Station & Unit:
Public Class Station
[code].....
I'm having problems doing a sort of a custom collection. The collection is Device Classes which is a collection of Device Class. My sort does not produce an error but the treeview control shows nothing. I am not sure what I am missing. I'm guessing just a simple sort won't work here but I don't know what I'm missing in my code. Here's the code that creates the collection
[Code]...
Simply sorting the treeview will not work because it throws off the display of related info for a given device in listview controls. The collection itself needs to be sorted before the data is added to the treeview.
I have a custom class that has one property as a collection.For some reason XmlSerializer doesnt like the class having a collection property and the Serialize Fails!If I remove the collection property it works! Is there a special way of getting the collection in the class to work?
View 1 RepliesI was wondering if its possible to bind a datagrid column to a list (Of T) thats stored within an observable collection!
Here's my current code:
Dim _BindWithThis As New List(Of BindWithThis)
Me.DataContext = _BindWithThis
For i = 0 To 3
[Code]....
This currently displays four rows of "(Collection)". Is it possible to step into one of these "Collection" rows and display the data? I know that this is possible to do with a list box by binding with a specific element in the collection:
ListBox1.ItemsSource = _BindWithThis.Item(0).DataValue
I just can't work out how to do this with a datagrid...
I can not find the collection on toolTips (I need to do this dynamically across forms).
vb
For Each theToolTip As ToolTip In getControls(theForm)
Next
error :Error 12 Value of type 'System.Windows.Forms.Control' cannot be converted to 'System.Windows.Forms.ToolTip'. C:UsersJeffDocumentsJeffWorkSpace2StudyX.NETModule1.vb 3690 51 study
I wanted to know if it's possible to remove a paticular item in my collection and then add it back at a certain location? e.g. say I use RemoveAt and remove the first item in the colleciton; after, I want to add it back at a particular location (index)? Maybe this isn't possible with this type or any other type collection?
View 6 RepliesI want to read a number of items from a file and then associate each of those items with a new button at run-time, so that when the user clicks one of the buttons I can display some information about that item.Can I use a LIST to manage these buttons and items? Can I create a new class and have each list item of that class, such as 'btnID', 'btnText', etc... ?
View 2 RepliesWhen ever I try to update a record from data grid using a dataAdapter record it always showing ' update requires a valid insert command when passed data row collection with new rows' From specific sql server Table only. Resulting me holding up a project.
View 4 RepliesI am trying to create an list or an array of a class.Here is my "Ingredient" class that I am trying to create a list of:[code]In my "recipe" class, I am want to create a list (or array) and I am drawing a big blank on how to do it. Can anyone point me in the right direction?
View 2 RepliesI'm trying to create a collection of variable binding in a class.It is intended to look something like this:
Dim x as integer, s as string
Dim c as new VBindClass
x = 1
s = "Hello"
[code]....
Is there some function that allow us to retrieve a unique ID for a given variable and also get/set based on variable?
Update:At last, I've managed to found the answer. Here's the code:
Dim gh As Runtime.InteropServices.GCHandle = Runtime.InteropServices.GCHandle.Alloc(obj)
Return Runtime.InteropServices.GCHandle.ToIntPtr(gh).ToInt64
I am moving from VB to C#. I am trying to loop through a collection class which is a collection of data classes but I can't seem to get the actual values out of the data class properties(find the correct code to do so). I have a method that loops through the collection class(Contacts) and saves each record(Contact). I am using reflection because my method will not know if it is Contacts class or a Customer class and so forth. Here is my code in VB(watered down)
Public Function SaveCollection(ByVal objCollection as Object, ByVal TableName as string, ByVal spSave as string)
Dim objClass as Object
[Code]....
The C# code keeps returning null. In my locals window I can see the proprties on the class on objClass and the value of the propery but I can seem to figure out how to access it through code. I used the DictionaryBase because that seems to closely match would I need to do. My data class(Contact) has a bunch or properties that match the field names in the database of the Contact Table. After I get the propInfo variable set I then set up my SQLParameter with the fieldname, datatype etc and then set the value to the propInfo.value.