2010 Collection Class Oddity

Sep 28, 2010

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 Replies


ADVERTISEMENT

Adding A List (of Class) Or Collection As Another Class's Property

Apr 2, 2010

I'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 Replies

Oddity In A MessageBox?

Jun 1, 2012

I have this

Dim st1 As String = sref.ConfirmLogin() 'A WCF method call.
Windows.Forms.MessageBox.Show(st1 & Environment.NewLine & "blue", "Result")

What is interesting about this is that there is no new line in the messagebox, and "blue" doesn't show up. If I reverse the order, then all is well. If I turn st1 into some other random string, all is well. However, as long as st1 is a string that comes from the WCF call, everything after st1 in the MessageBox is ignored.So what is coming from the WCF call?

The lines are these:

resp.GetResponseStream.Read(buff, 0, 99)
Return Encoding.ASCII.GetString(buff)

resp is a WebResponse object, though that shouldn't matter, as the key is that I take a stream, move it to a buffer, then turn that buffer into a string. What is it about the string that is alterning the way the string is displayed.If I highlight the "st1 & "Blue"" part, and press Shift+F9, it is all there. What I do notice is that there is a significant space beyond the end of st1 and before the Blue. Trim doesn't get rid of this space. My theory is that what is there is a series of Null bytes, and MessageBox is interpreting that as the end of the string and terminating the display at that point, even though it shouldn't really be terminated there. That's especially interesting because I can add in an Environment.NewLine, which would normally add a new line, but even that gets ignored.

View 5 Replies

Base Class Collection With Sub Class Objects

Jul 19, 2010

[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 Replies

Passing List / Collection From Class To Class

Apr 28, 2009

I 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 Replies

Interesting Oddity With System.random Utilization

May 24, 2012

I've been utilizing the pseudo random number generator provided by system.random, and interestingly, and I utilize the code vara.next(1, 10000001), and repeat this code every one second, to get a number between 1 and ten million, I never get any numbers lower than 100,000. This is really weird, ne ideas? Does the prng spaz out with a value that high, or are we looking at a 'magical', or perhaps non-physical explanation here.. I know that idea may blow your mind, but we do live in an age where consciousness is seen as a permeating force more and more in psychology and metaphysics.

View 1 Replies

VS 2005 Data Grid View Oddity

May 28, 2009

I'm working with a DataGridView. The DataSource for the DataGridView is set to a DataTable that I've populated with the results of a SQL query.

Then, I add an extra column to the DataGridView, a DataGridViewCheckBoxColumn. This allows the user to select a number of records in the datatable in order to save out selected files, represented by the rows of the datatable/DataGridView.

I have buttons that will programmatically check/uncheck all of these CheckBoxes, as there are frequently several hundred rows in the DataGridView. The user can also check/uncheck any number manually.[CODE..]

View 8 Replies

Bug In Collection Class VB?

Aug 16, 2009

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.

View 2 Replies

Collection, Class .. Which Is Best For Example

May 25, 2009

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?

View 3 Replies

Composite Key With Class Collection?

Jun 17, 2011

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 Replies

.net - Set An Incrementing ID Property To A Class' Collection?

Nov 15, 2011

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]....

View 2 Replies

A Property In A Class Is A Collection Of Objects

Jan 29, 2009

Thought I had got this sorted earlier but unfortunately not. A property in a class is a collection of objects.

[Code]...

View 4 Replies

Getting An Error With  A For....Each Loop For A Collection Class?

Sep 1, 2010

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 Replies

Retrieve A Property Of A Class As A Collection?

May 26, 2012

I'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].....

View 1 Replies

Sort Of A Collection Of Class Objects?

Feb 28, 2012

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.

View 6 Replies

XmlSerializer To Serialze A Class With A Collection?

May 26, 2010

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 Replies

C# - Create A Collection Of Variable Binding In A Class?

Apr 15, 2010

I'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

View 2 Replies

C# - Find And Insert Into List Class Collection?

Mar 10, 2011

I have class called GroupSelect and made a collection List(Of GroupSelect)().[code]...

View 1 Replies

C# Accessing Properties Of An Object From A Collection Class?

Jun 10, 2009

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.

View 5 Replies

Change Base Class Collection DataType?

Dec 4, 2009

Is there a way to change a base class type by Overrides or Shadows, or other meen?[code]...

In this example there is MyBaseClasswitch is the base Class, then ClassB that Inherits from MyBaseClass, and In ClassB I try to overrides the base property "MyColl" to change is type to a enum.

But it do not work, telling me that the base collection cannot convert to eCarBrand, blah blah blah

Is there other way to change base class type or other approach that a could use?

View 12 Replies

How To Create Collection Class And Add List Of Items

Oct 13, 2009

How to create collection class and add list of items to collection class that stores list of items?

View 3 Replies

Initializing Class Collection Of Inherited Types

Oct 4, 2010

Is there a way to have a class collection of inherited types be initialized? For example, here is my code:
Public Class CamryCar
Property Name As String = "Camry"
Property Color As String
End Class
Public Class RedCamry
[Code] .....

I prefer this one as I don't have an extra property to deal with. But I can find a way to initialize that that list with objects of RedCamry and BlueCamry. Is it impossible or is there another way to do this?

View 3 Replies

Setup A Customer Collection Class That Has One Function?

Jan 15, 2012

I am having trouble setting up these classes.I need to set up a customer collection class that has one function GetCustomer(ByVal customerNumber As Integer) As Customer..The customer class reads a file and returns 5 fields and x number of records.My question is do I set up the 5 properties (fields) in the Customer class and if there are 10 records that match how do I return the customer object to the customer collection class. I don't care about exact syntax but could someone show me how these 2 classes should look?

View 2 Replies

VS 2008 Binding Collection Class To Listbox?

Oct 17, 2011

using a Binding Source to Bind my Collection to a ListBox? I can bind the class to the binding source, but im not sure how to let it know what type of list it is, or how to display the correct item.

I'm trying to get the listbox to display the ItemNames. Here's my class and collection class.

<System.Serializable()> Public Class SurveyItem
Private itemNm As String
Property ItemName() As String

[Code]....

View 1 Replies

Datatable Object Within Class Function + Garbage Collection?

Oct 6, 2009

Datatable object within class function + garbage collection?

View 3 Replies

DNN Dal+ - Retrieve Individual Info Class Collection Items?

Dec 30, 2010

I can't seem to find any answers that work. Here's the setup:

Info class: Public Class ProductStageInfo

[Code]...

maybe I just don't understand the whole collection/index/thing. All the examples I've found are regarding single dimension collections - 'how to find name within this collection', and the responses use strings to search through them, but somehow the Info class is being treated differently, and I'm not sure how to translate this..

View 1 Replies

Custom Collection Class Bound To DataGridView Text Formatting?

Aug 14, 2011

I have a custom collection class that is bound to a data grid view object.I'd like to try to do the following from the custom element class if possible.

1) I'd like the name of the column header to be a different text than the name of the public property in the custom class. i.e. Trade_Name should read "Trade Name"

2) I'd like to try to be able to manipulate the text formatting/color of the individual collection class element's items. i.e. for a profit/loss field I'd like to have the numbers be red if they are loss and black of they are profit. I know I could do this from the datagridview object in the form, but that can be cumbersome to raise events etc.

View 2 Replies

Alter Items Added To Generic Collection (as Property Of Custom Class)

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

Class Collection Property - Method - Allow For An Employee To Be Assigned More Than One Work Location

Jun 17, 2011

I am experimenting with a transition from my application built in VB6 to vb.net. I know, about time. At the same time, i am making changes and improving upon the original. One area that I am working on is within my employee class. very standard class, nothing fancy. One change I want to make though is allow for an employee to be assigned more than one work location. Employee has (is assigned) Stores. In reading about collections, it appears they are different in .net (as they should be), but I don't know what the sytax changes will be to implement my changes.

View 6 Replies

IDE - VB - Business Logic - Unable To Inherit Or Call The Location Collection Class

Feb 17, 2010

my form displays locations and owners for a same product, the forms have a data grid view that actually takes in the details of the location and owner of that particular product. a product can have multiple owners and locations once its manufactured over time, the forms actually display this all i need is some kind of business logic that can actually manage the historical events of the location and the owner that when a user actually goes in and adds a new entry, the end date of the previous owner gets reduced to one less than the start date of the new owner. this in formation is stored in business layers called the owner collection and the location collection, i am not able to actually inherit or call the location or the owner collection class in the classes.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved