Sorting Generic List On Multiple Keys?

Nov 2, 2009

I need to sort a list (of person) to person.Age within person.Department. f I user personlist.sort with a comparer for Age and then sort again with a comparer for Department, the sequence of age is destroyed.

View 1 Replies


ADVERTISEMENT

Sorting System.Collections.Generic.List?

Feb 2, 2012

I have a lists of different custom classes and each must be sorted severals times before the algorithm is complete. For each sort I wrote a comparer. Sofar so good. Everything works. But: By now I have abou a dozen different comparers in more than one class and it is still getting more. I wonder if there is a way to limit the number by writing a new general function that can be used to sort all lists without the need for a specific comparer.Below is what I've got so far. But it does not work.

"System.Collections.Generic.List(Of ClassA)" can not be converted into "System.Collections.Generic.List(Of Object)."

[code].....

View 2 Replies

Combing Multiple Columns For Sorting With Generic Member Expressions

May 20, 2011

I've followed examples here and here to create a generic sort with memberexpressions, but how I'm supposed to add a "ThenBy" clause, or combine multiple columns for sorting in the methodcallexpression. Ideally, the ThenBy should go before skip, but it can't because it can't see the orderby clause that I made with the methodcallexpression. GridSortExpression is a Telerik class - it just describes which column and direction the query should be sorted.

Here is what I have right now:
Dim exp As Expressions.Expression(Of Func(Of Product_Catalog, Boolean)) = PredicateBuilder.True(Of Product_Catalog)()
exp = exp.And(Function(e) e.Chapter_Price > 30)
Dim sortExpression As New List(Of GridSortExpression)({New GridSortExpression() With {.SortOrder = GridSortOrder.Descending, .FieldName = "Id"}})
[Code] .....

View 1 Replies

Sorting List (Of Structure) - Sort Multiple Variables

Feb 17, 2011

I'm using a Listview in VirtualMode, so I can 'add' a lot of files almost instantly. A Listview in VirtualMode does not allow sorting, so I need to sort the data myself. The data is stored as a List of Structure (it's faster to load than a List of ListViewItem). The code below works fine, but I need to sort based on multiple variables in the Structure. Code:

View 2 Replies

[2008] Working With A Generic List (multiple Manipulators)

Mar 14, 2009

so I have a generic list in a console application. Dim Channels as New List(Of Chatroom) Chatroom is a structure. But I have multiple classes, threads, and timers looping through this list, sometimes at the same time, but it always seems to raise errors because the number of items in the list gets changed while one of the other classes/threads/timers are looping through also. Is there any way to allow only one to manipulate it at a time?

View 8 Replies

Excel Sorting Is Only Sorting One Column Not Multiple?

Mar 12, 2012

I'm having my program sort an excel sheet by a few columns. However, it is only sorting by the first column not the rest that I specify.ere is my sort code below:

myRange.Sort(Key1:=myRange.Range("A:A"), Order1:=XlSortOrder.xlAscending, Key2:=myRange.Range("G:G"), Order2:=XlSortOrder.xlAscending, Header:=XlYesNoGuess.xlYes, Orientation:=XlSortOrientation.xlSortColumns)

[code]...

View 1 Replies

Loop Through A List Of The Keys That Are Available In The 'Keys' Enumeration?

Jan 13, 2011

How could I loop through a list of the keys that are available in the 'Keys' enumeration? It seems like it should be something easy to do, but I'm not having any luck finding a collection that I can loop through.

View 6 Replies

.net - Creating A Generic List Of A Generic Type

Jun 30, 2011

I am trying to create a list of a generic type in vb.net 2.0 framework.
This is the generic type definition:

Public Class GenericParamMap(Of T)
Public Sub New(ByVal pParamName As String, ByVal pPropValue As T)
mParamName = pParamName

[Code]....

The compiler does not allow a "T" in the method's parameter because it's not defined, but I'm not sure how or where to define it. I thought it was okay to have a generic method definition.

View 2 Replies

Insert Into A Generic Dictionary With Possibility Of Duplicate Keys?

Apr 2, 2010

Is there any reason to favor one of these approaches over the other when inserting into a generic dictionary with the possibility of a key conflict? I'm building an in-memory version of a static collection so in the case of a conflict it doesn't matter whether the old or new value is used.

If Not mySettings.ContainsKey(key) Then
mySettings.Add(key, Value)
End If

[code].....

View 4 Replies

Raise Events - Generic Function For Sorting Integer Arrays

Aug 26, 2010

I am very confuse over a Raise Events example and using delegate as a function pointer: I am clear with this function pointer example program below which creates a generic sort function for sorting integer arrays without changing the main sort function.
' Returns True if need to swap
Delegate Function CompareFunc(ByVal x As Integer, _
ByVal y As Integer) _
As Boolean

Here are two alternative target methods for the delegate - one for an ascending sort and one for a descending sort:
Function SortAscending(ByVal x As Integer, ByVal y As Integer) As Boolean
If y < x Then
SortAscending = True
End If
End Function
Function SortDescending(ByVal x As Integer, _
ByVal y As Integer) As Boolean
[Code] .....

View 1 Replies

File I/O And Registry :: Listing Multiple Regkeys Under Multiple Keys?

Jun 13, 2012

I am trying to list all printers (PrintersConnections) under all users (HKEY_USERS)

problem is I dont know the user name keys in advance and need to exclude .DEFAULT and *_CLASSES so first I need to list all key names (%usernamekey%) directly under HKEY_USERS then for all keys that lists lsit all keys under HKEY_USERS\%usernamekey%PrintersConnections

Here is the code I have so far but I get errors about object variable not set, I suspect because of the way I doing the for each and listing the key names and then doing it again

Code:
Private Sub DetectPrntrs()
Try
Dim RemReg As Microsoft.Win32.RegistryKey

[Code].....

View 2 Replies

Determine If Property Is Generic List<of T> Via Reflection And Loop List Items

Oct 1, 2009

I'm looping all the properties in an object via reflection:

For Each p As PropertyInfo In values.[GetType]().GetProperties()
If p.CanRead Then
'Do stuff
End If
Next

how to determine whether the property in question is a generic List(Of T)? If it is I need to loop the list itself.

I've experimented with GetType and TypeOf but have not managed to get anything working.

To clarify, I want to keep this generic. I do not want to specify the type of T, I need to loop the list items and call the ToString method on each item. T could be one of a number of different types (application specific reference types). Is it possible to do this without specifying types?

(VB.NET 2005 with .Net 2.0)

View 3 Replies

Get Type Of Derived Generic List Class From List Item Method?

Mar 23, 2011

Public Class notifierMain
Public Class Contacts
Inherits List(Of row)
Public Sub New()

[code]....

When I debug this winforms application I get curType = "notifier.notifierMain+Contacts+row" I want to the Validate function to know it is in MyContacts. How do I do this?

View 3 Replies

.net - Returning A List Using Entity Framework, 'System.Collections.Generic.List Cannot Be Converted To '1-dimensional Array

May 3, 2012

i have issue returning a list in a web method. here is the code

<WebMethod()> _
Public Function getTags(para_parents As String) As List(Of getTypeDetailsByParentName_Result)()
Dim context As New PPEntities

[code]....

the error is

Value of type 'System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)' cannot be converted to '1-dimensional array of System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)'

View 1 Replies

Pass Generic List To A Function That Has A Custom Defined List

Apr 7, 2011

it seems always at this time I cant figure out how to do something maybe it has something to do with lunchtime.

Im having trouble using a method that is defined by an outside company

This is a link to their integration guide:

[URL]

This is their documentation for the class Im trying to use

OrderQueryWebService Class

This class is for SID in particular and is made for use with the notification methods. This is for the Order Query Web Service specifically, allowing clients to return the status of transactions for their merchant, whenever they want to.

Methods
/ <summary>
/ Pass through the variables required and receive a list of Transaction
objects showing transaction status

[Code].....

The MerchantCode, the MerchantUsername, the MerchantPassword are all good the List is a custom type called SetComHash.Transaction

Everytime I try adding a string to the list such as the transactionNumber and some other values it gives me a type error:

"Value of type string cannot be converted to 'SetcomHash.Transaction'

View 13 Replies

.net - Sort Generic List Based Upon A Different List?

Oct 29, 2010

What would be the fastest way to sort a list that contains a list of objects, based upon another list? An example follows:Say I have multiple lists of employees. Each individual list has a common property value, say "Department". So I have a list of employees, in one list they all have the department string value of "Sales". In another list all the objects have a department value of "Finance". These lists of employees are then contained in a list which holds them all.

I have a second list, which should drives the sort order of the employee lists. The second list simply contains a list of strings like, "Finance", "Sales", "IT" and so on. I'd like my lists of customers to be sorted in the order of "Finance", "Sales", etc.I'm using VB.NET in .NET 2.0

View 1 Replies

Generic TypeOf Operator - See If List Is A List(Of T) Variable - Error: "Type Expected"?

Jan 5, 2011

Dim x = GetType(List(Of )) 'valid statement
Dim list As New List(Of String)

Now I want to see if list is a List(Of T) variable: Dim isList = TypeOf list Is List(Of ) On the last line I get a compile error: "Type Expected". Is there any cheap-performance TypeOf operator alternative for generics?

View 2 Replies

Error - Red "List" Says Too Few Type Arguments To System.Collections.Generic.List(Of T)'

Mar 12, 2009

I have converted c# .cs to vb:= I have 6 errors on:

Red "List" says Too few type arguments to system.Collections.Generic.List(Of T)'
Orange "Calendar" says Value of type 'System.Windows.Forms.Control.ControlCollection' cannot be converted to 'Form1.Kobush.Windows.Forms.Appointment'.

[code]....

View 6 Replies

DB/Reporting :: Multiple Sorting In CR .NET

Apr 1, 2008

I plan to do a multiple sorting in crystal report programmatically... but i encounter some error... prehaps someone can guide me through

Dim crfd4sort As FieldDefinition

strSort = "ITEMNO_PRT, INSNO_PRT, VALUE_PRT, DATE_PRT"

[CODE]...

View 3 Replies

Multiple Hot Keys Instead Of Assigning One

Jan 13, 2012

I'm creating a project that involves hot keys, but it requires multiple hot keys instead of assigning one. I'm going to make it so if a user presses for example CTRL + T on they keyboard while a textbox is selected, it'll show CTRL+T in the textbox and assign the key to do something. How do I do these though? Here's the code I've used for single hot keys:

[Code]...

View 1 Replies

DataGridView Multiple Column Sorting

Jun 9, 2009

I'm trying to sort multple colums in the DataGridView which is unbound. I would prefer to sort by using a DataTable/DataView but for some reason another developer in my team experienced other problems relating to sorting so he abandoned using the DataTable to fill the grid :(

Here is the senario: I want the user to be able to choose which columns they want sort on. The way I envisaged was to show a form with a listbox, a grid and 3 buttons (Add to sort, Remove from sort and Apply Sort).

The list box would be populated from the parent form grid column headings.
The grid will show the columns and sort direction.
Button 1 would add the selected item of the list box to the grid.
Button 2 would remove from the grid the selected row.
Button 3 would Apply the Sort in the order of the grid and the columns SortDirection.

Now I looked at How to: Customize Sorting in the Windows Forms DataGridView Control using the IComparer [URL]

how I can use the IComparer to sort on multiple columns that a user has specified or another way to sort on multiple columns using unbound data.

View 3 Replies

Pressing Multiple Keys At The Same Time?

Oct 7, 2009

im trying to make a two player game in vb 2008, it involves to ships either side of the screen shooting at each other.

A problem that ive found is that my code or vb wont recognize two keyboard inputs at the same time.

Private Sub Form3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode

[Code]....

View 2 Replies

Reading Multiple Registry Keys?

Aug 18, 2010

I'm trying write a code that will check the framework version on the same computer it runs.

Now this code has to be able to run on every machine regardless the frameowrk version on it.

Now, i know how to read one registery key, but i don't know how to check muliple keys.

For example "HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP"

Under the key "NDP" there are a couple of more keys, how can i get the keys name?

View 2 Replies

Sorting A Class Of Multiple Properties?

Oct 13, 2011

I have created a Class, basically like this:

Public Class Person
Implements IEquatable(Of Person)
Public Sub New(ByVal Name As String, Optional ByVal Like As Boolean = True)
Me.Name = Name

[Code]...

View 4 Replies

Sorting Multiple ArrayLists Alphabetically

Sep 26, 2011

I've got three arraylists of strings, and the "091: " part of the string is not part in the arraylist, thats added when I display them in the listboxes. So basically, how can I sort a list, and make sure that item nr 98 in english, still equals nr 98 in japanese and kanji?

View 11 Replies

Exception When Sorting List

Jan 29, 2010

I'm trying to sort a List of objects with a generic comparison.I get an exception when the property on which I'm sorting happens to be null in one of the objects.VB.NET 2.0, web.i've read several posts on this exception, and still don't get it.[code]It is true that this only happens on properties which happen to be null somewhere in the list.Sometimes I sort on other properties which happen to always be always non-null (using a different, but similar, comparison method), and this technique works just fine.I've tried to implement the CompareTo for both IComparable and IComparable(of FollowupSurvey) so I could capture this exception while debugging, but netiher actually get invoked (despite what it seems like the exception is telling me). At this point, I don't have a CompareTo in my FollowupSurvey object; thus, it's using Object's.It doesn't seem as if I can really help if the base CompareTo doesn't reutrn 0.anyone have any idea what this exception really means, and how to make sorting work properly?

View 2 Replies

Get List Of ALL Registry Sub Keys?

Mar 8, 2012

I want to get all sub keys in a reg location. This entry can also have additional sub keys.At location "HKEY_CLASSES_ROOTexefile" this key as 3 subkeys and 2 of these keys have additional sub keys under them. I need to get all the keys and any additional sub keys under each key if there is any. This code will be used for other keys, so I can not assume they have subkeys.

Dim Key As RegistryKey = Registry.ClassesRoot.OpenSubKey("exefile", False)
Dim SubKeyNames() As String = Key.GetSubKeyNames()
Dim Index As Integer

[code]....

View 2 Replies

Sorting A List By A Class Value

Jun 25, 2011

I have a list (i.e. Dim nList as new List(of className)). Each class has a property named zIndex (i.e. className.zIndex). Is it possible to sort the elements of the list by the zIndex variable in all of the elements of the list?

View 4 Replies

Sorting A List Of Objects?

Mar 16, 2012

Suppose I have:

Public Class myClass1
Dim foo As String
Dim bar As String

[code].....

View 23 Replies

Sorting Within A List Of Type's?

Jan 30, 2010

I have a simple type like:-

[Code]....

if I have a list of type top_params then how can i sort the list based values in the k_sig_level field?

View 2 Replies







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