Use Custom Comparer When Sorting By Multiple Columns?

Apr 7, 2011

I have a ListView (GridView) that I want to sort by 2 columns, so if 2+ items have the same value in Column 1, it sorts by Column 2. Pretty easy. But empty strings show up at the top when sorting A-Z. I'd like to move them to the bottom. I made a comparer (IComparer) that takes care of this, but I'm not sure how to use it.[code]...

View 1 Replies


ADVERTISEMENT

.net - SortedDictionary - Comparer Only For Sorting

Oct 31, 2010

I have a list of keys and values that I would like sorted by key via a custom Comparer(Of T). I tried using a SortedDictionary, but kept getting incorrect results because it used the comparer to see if the items were the same. For example calling SortedDictionary.ContainsKey() would return false, even though it did contain the key.

When I stepped through the code after calling ContainsKey(), it would go to the comparer.Compare(x, y) function. It would then only compare against a few of the keys in the dicionary, and somehow skip the matching item (which I ensured did exist). I take it that this is some sort of optimization, where some items are skipped depending on what is returned by the comparer.Compare() function? Is it possible to have a dictionary that only uses the comparer for sorting? EDIT: I am using a Type object for the dictionary's key

[Code]....

View 3 Replies

Asp.net - Reverse-sorting A Listview (with Comparer Class)

Oct 7, 2009

I have a two-column ListView linked to a Datapager. The ListView lists all files of a particular type in a particular directory, so the data source is an ArrayList of type FileInfo. Consequently, I had to create a Comparer class to use in the ArrayList.Sort method.

[Code]...

View 3 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

LINQ Except Using Custom Comparer?

Jun 17, 2009

[code]....

View 4 Replies

VS 2010 - Write A Custom Comparer To Make A Listbox Full Of Numbers Sort Itself

Jan 17, 2012

So...numeric sorts. Do I really need to write a custom comparer to make a listbox full of numbers sort itself like:

[Code]...

View 4 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

Sorting A Databound Columns?

Mar 7, 2012

I have a datagridview in VB.NET in which i have few columns which are data bound . How to sort a databound column which contains names ?

View 7 Replies

Sorting By Columns With Datagridview?

Nov 1, 2010

Is it possible to sort a datagridview by column when a user clicks a column header? I have the sort method set to automatic under each column, which from what I read, is what I need. I know this has to be insanely easy....

View 7 Replies

DataGridView - Removing Columns And Sorting?

Mar 10, 2009

Is it possible to remove from a datagrid view very first "column" i.e. the row selector and also to remove the ability to reorder the columns ?

View 3 Replies

DataGridView Sorting On Columns Not Working?

Apr 28, 2010

I'm using vb 2005, seems sorting is not working if I change the data by code. For example, if I have a simple form with only one datagridview and one button, grid was sorted on column 1, then I press the button to randomly change data in column 2, then use column 2 to sort, the display order is not correct, but after the button click, if I click on a cell, the grid will re-sort by itself, and get the right list. I know DataGridView is not for Editing data...

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("C1")
[Code] .....

View 4 Replies

Error In Sorting Datagridview's Columns?

Oct 7, 2009

I have a datagridview and all its columns are set to Double Datatype. The problem is when I changed the value of cell and try to sort the column, it shows me an error "Object must be of type Double." I check each cell but all its values are number and I can sort all the columns before I edit one cell. But when I tried to change the value of only one cell and sort the columns, the errors will show. Its weird because I only removed 1 digit of the cell value and I cant sort at all.

Code:
Dim col As New DataGridViewTextBoxColumn
col.ValueType = GetType(Double)

[code].....

View 1 Replies

Sorting Columns In A Listview Object?

Jun 22, 2009

First off i just want to take a bow to all the vb gods out there..I am trying to implement the sorting class form article 319399 in the knowledge base [URl]..on step number 6 it says to "Paste the following code into the ColumnClick event for the ListView:"so i created a sub to handle the ColumnClick event

[Code]...

View 2 Replies

VS 2005 Datagridview Columns Not Sorting?

Sep 23, 2010

I have a datagridview that is bound to a datatable. When the form is displayed, the column headers have no sort glyphs and the columns will not sort.

I don't see a property on the form that controls column sorting - at least not one that's obvious. This is an area of the code that another developer wrote originally, so maybe there's something going on that I'm not aware of.

View 6 Replies

Asp.net - GridView SORTING Of DYNAMIC Columns And Data Source Scope

Aug 5, 2011

I re-wrote this to make it more readable. If you want to skip right to the chase, look at the ALL CAPS comments in the code blocks. All necessary code has been included for debugging. I've searched multiple forums (including ASP.NET), and the MSDN library and cannot fix this >.<

[Code]....

View 2 Replies

GridView SORTING Of DYNAMIC Columns And Data Source Scope?

Jul 9, 2011

GridView SORTING of DYNAMIC Columns and Data Source Scope

View 2 Replies

Custom Row Sorting In A DataGridView?

Jun 5, 2011

I have a DataGridView that is being populated via SQL with one table and is being filtered by Stock Code. I need to sort the view of one Stock Code by Nutrient names, but the sequence number is in anther SQL table. it would be easy if i could put the sequence in one table but that's not possible

View 2 Replies

Asp.net - ASPxGridview Custom Sorting By Month Name?

Oct 10, 2010

I have an aspxgridview which groups first by year and then by month. Basically my query returns Month and year as seperate columns. Now if I return month as "January or February" then ASPxGridview does not know how to sort this.

I heard of custom sorting, but even then if I return month column as a number and use dataitem template to convert it to a name...it works but then when exporting it only exports the number not the dataitemtemplate.

View 1 Replies

Sorting A List Based On An ArrayList Within A Custom Object

May 24, 2010

I am using a list to keep track of a number of custom Row objects as follows:

Public Rows As List(Of Row)()
Row has 2 properties, Key (a String) and Cells (an ArrayList).

I need to be able to sort each Row within Rows based on a developer defined index of the Cells ArrayList.

So for example based on the following Rows

Row1.Cells = ("b", "12")
Row2.Cells = ("a", "23")

Rows.Sort(0) would result in Row2 being first in the Rows list. What would be the best way of going about implementing this?

View 2 Replies

Sorting Items In A Custom Class According To Item Values?

Oct 8, 2009

I have the following in my main form

Class MainWindow
Public TableDetails As New List(Of TableDetailsContainer(Of TableXDetails))
Public Sub ArrangeByID()
'''STUCK HERE''''

[code].....

What I basically want to achieve is to sort TableDetails(i) items by their "ID", but I have absolutely no idea how to go about it. Could anyone please give me pointers?Also, I actually want to move the columns within TableDetails(i) around, manually. But I'm not too sure how to do that.

View 6 Replies

Dataset - Multiple Tables - Multiple Columns

Sep 18, 2009

I have a small project i am doing for work to compare our website catalogue to our actual inventory in our financial software. To do this, i have exported the online catalogue as a delimited text file using "^" as the delimiter. I then want to go into our Accpac data a find out if all the items are still active, the current price and the stock on hand.

[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

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

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

DataGridView And DataBinding With Custom Columns

Sep 9, 2010

My requirement is as follows, I am calling a procedure and I'm populating a DataTable. Assume that the procedure is returning emp_id, emp_name, designation and status. When I use DataGridView1.DataSource = <Name of the DataTable>, I get all the columns populated into the DataGridView. How can I display only selected columns in the DataGridView. For e.g, I want to show only emp_id and emp_name.Similarly, as to how I can increase the width of the columns of the DataGridView by writing code.

View 3 Replies

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

Add Custom Columns To A Table That LINQ To SQL Can Translate To SQL

Aug 26, 2009

I have a table that contains procedure codes among other data (let's call it "MyData"). I have another table that contains valid procedure codes, their descriptions, and the dates on which those codes are valid. Every time I want to report on MyData and include the procedure description, I have to do a lookup similar to this:

From m in dc.MyDatas _
Join p in dc.Procedures On m.proc_code Equals p.proc_code _
Where p.start_date <= m.event_date _

[Code]....

Is there a way to turn a complex lookup (i.e. a non-trivial join) like this into something SQL can recognize so that I can define it in one place and just reference the description as if it were a field in MyData? So far the only thing I can think of is to create a SQL view on MyData that does the linking and bring that into my data context, but I'd like to try to avoid that.

View 2 Replies

Custom List / DGV For Auto-wrapping Columns

Dec 19, 2009

I attached a screenshot of my IRIS program and am wanting to implement a new feature, but I'm not sure how to do it. On the left hand side, you can see I have a bound datagridview control that displays a device name and an IP Address from a table in a database.What I want to do is have the option to launch a new form that has ALL the devices visible (including their state: green or red) and based on the size of the form, be able to auto-wrap to a new column.[code]So basically, instead of being able to only see the devices in the DGV on the left as it is scanning, I want to be able to see ALL of the devices in multiple columns in a new form. I looked on codeproject for a custom control to do this, but didn't really find anything.

View 5 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







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