C# - Sort On Multiple Columns In WPF Datagrid?

Jun 24, 2011

How can I set up my WPF datagrid to sort on multiple columns similar to having two sortable columns, clicking on the header of the first column for a primary sort and then SHIFT clicking on the header of the second column for a secondary sort. I would like the multiple column sort to happen automatically when the user clicks on the header of the first column without having to SHIFT click on the second column header. Is there a way to do this entirely in the xaml? If not how can I do this in the code behind? Currently using VB.Net but a C# snippet is acceptable if you have one.

View 2 Replies


ADVERTISEMENT

Sort Datagridview By Multiple Columns?

Jul 19, 2011

How do I sort a DGV by multiple columns.

View 1 Replies

VS 2010 : Datagrid Multiple Column Sort?

Jan 19, 2012

I have a table with two columns, date and time. I am using the following code to sort in descending date order.

VB
If historydataGrid.Rows.Count > 0 Then
'if there are rows, sort by date (most recent first)
historydataGrid.Sort(historydataGrid.Columns(0), System.ComponentModel.ListSortDirection.Descending)
End If

Where Columns(0) is the Date. However, how difficult is it for me to then sort secondarily by time. So that the grid will sort by most recent date and time.. Working down from the most recent time on the most recent date, and then moving backwards towards the oldest date with the oldest time.

View 3 Replies

VS 2008 : Add Multiple Columns To Datagrid?

Nov 20, 2010

I want to add more than one column to a grid...The following does NOT work, how can i do it?

Dim AmountRounds As Integer
DataGridView1.ColumnCount = Amount + 2
Dim contcolumn As New DataGridViewTextBoxColumn
For AmountRounds = 1 To Amount - 1

[code]....

View 1 Replies

How To Display Multiple Columns In Datagrid View

Jan 25, 2010

I read data from a xml file and display all the contents in datagrid view. I want to extract collection of columns with same or similar contents - i.e I have three columns A,B,C and five rows in xml file. In column C, row no. 1,3,5 is filled with 'X's and row no. 2,4 is filled with 'Y's. I want to extract all columns which is related to the Columns C's content 'X'.Right now I am only able to extract one column which is related to X from Column C. How can I fix this ??

[Code]...

View 1 Replies

Sort Dgv By 2 Columns?

Dec 10, 2009

I'm sure this has been asked here before but i couldn't find it, anyway my issue is i have filled a dgv using a LINQ query and i need to sort my results by 2 columns, i.e. type and cost so that it lists items by each type in creasing cost[code]...

View 10 Replies

How To Sort By Columns In A Datatable

Sep 1, 2011

I currently have a datagridview that is built from a datatable So lets say we have 6 columns

A B C D E G

So the users will select there data from another program and paste into the the table. So lets assume that the data that is pasted is; (the column names are automatically put in)

A B C D E G
123 456 789 101 112 134

So the table will now look like following (I remove the first row because its the same as the column name)

A B C D E G
A B C D E G
123 456 789 101 112 134

My problem is that the users can rearrange thier tables(column index) so lets say user A has the table in this format

A B D E C G
123 456 101 112 789 134

So when they paste into the program, it will look like

A B C D E G
A B D E C G
123 456 101 112 789 134

So now "C" "D" "E" are incorrect and i need to swap those columns to be the same as the column name. I'm not sure how to attack this problem.My thoughts were to paste the data as is, than see what the first row in each column equals.so if it equals "A" assign it an index 0

B 1
C 2

This seems theres too many steps and will slow down the app...

View 2 Replies

Sort A Datagridview By Several Columns?

Nov 30, 2009

How do i sort a datagridview by several columns?

I want to sort the data in my DataGridView by the Title, Location and Reference, i have the following to sort the DGV by title, how can i include the two other columns in the sort?[code]...

View 11 Replies

Sort Out Two Columns So When Click Them?

May 26, 2012

how would you sort out two columns so when you click them, it either sorts the listed items in Ascending/Descending order. I have named Name column to colName and Mobile column to colMobile

View 10 Replies

Sort Different Columns Of Different Type Of Listview ?

Apr 16, 2012

Using Microsoft Visual Studio 2010 Ultimate - VB.Net

I'm writing an application where as many of other applications fulfill the requirements to be as an app , having it's statistics schema. Thus I made a form where I have a combox(of query category), a textbox(as searchfield), two datetimepickers(from and to) a listview and a button to fire the event with functions in it. I'm all set except for a minor issue I've encountered during my very first experiments with ListView control. Thus far I didn't know that VB users are stuck with that control's property options (whereas DataGridView has way too many), especially when it came to Column reordering/s. With the simple but not satisfying property Sort I couldn't find a proper solution to my issue.

when I click on of the columns in the listview to do a Number/Date/Text reordering (descending>ascending, via-verse). Not to forget to mention there a limited number of columns most likely 2-4 max.

The listview control has lvResults name and has for now columns inserted as "Country" and the other for subitems "Total Spent".

One e.g. of the values inserted to it is like this :

[Code].....

If pressed on Total Spent, should reorder from highest to the lowest number and via-versa. If pressed on Country should reorder from A to Z or via-versa.

View 3 Replies

VS 2008 : DataGridView Sort By 2 Columns?

Mar 26, 2009

How do I sort a DGV by 2 columns? The DGV is not bound.

View 4 Replies

VS 2008 : Sort Columns In Listview?

Apr 16, 2009

I'm trying to set something up where the user can sort each column by clicking on the header... i've looked at some other examples and they seem pretty longwinded..so far i have the below...

VB
Private Sub resultsListView_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles resultsListView.ColumnClick
Dim oldsort As SortOrder

[code]....

which works fine... but only for the first column in the list view.Is there a way of specifying which column to sort based on which is clicked?

View 8 Replies

Asp.net - Sort Gridview Columns Ascending And Descending

Jul 25, 2011

I am trying to program my page in vb.net and asp.net so that when a user clicks on a column heading of a gridview, the data is sorted either in ascending or descending order. note that my data is coming from an SQL Server Express database. So far, I have done it so that the gridview can be sorted:

[Code]...

View 2 Replies

Ranking Excel Columns Based On A Sort?

Mar 23, 2012

I fought through a good amount of this and have gotten to the point where I can sort my arrays. What I need to do now is take the following code and sort the elements in descending order instead of ascending order. I don't know how to do that with the two arguments in the code:

Dim Cols(3) As Int16
Cols(0) = ColumnNumber + 1
Cols(1) = ColumnNumber + 2
Cols(2) = ColumnNumber + 3

[Code].....

View 1 Replies

Sort The Data By Columns In A List View?

Jun 22, 2010

how do you sort the data by columns in a list view, for example, clicking the title of the column to sort by ascending order.

View 3 Replies

.net - Sort Datagridview Columns When Datasource Binded To List(Of T)?

Feb 4, 2011

I have a datagridview with its datasource binded to a List(Of T). Now i would like to sort on any of the columns.My code:

'Database access : items = List(BlogPost)
dgBlogPosts.DataSource = items
'My BlogPost Class
Public Class BlogPost

[Code]...

View 1 Replies

Conditional OrderBy - Number Of Columns User Can Sort By (Name, County, Active)

Jun 17, 2010

I've got a number of columns the user can sort by (Name, County, Active) and that's easy but messy. Looks something like this...

Select Case e.SortExpression
Case "Name"
If (isDescending) Then

[CODE]...

What I would LIKE to do, is something more ... like this

Private Function SortThatList(ByVal listOfStuff As List(Of Stuff), ByVal isDescending As Boolean, ByVal expression As Func(Of Stuff)) As List(Of Stuff)
If (isDescending) Then

[CODE]...

But it doesn't like the datatype (Of TKey) ... I've tired Func(Of stuff, boolean) (got something in c# that works nicely like that) but can't seem to get this one to do what I want.What's the magic syntax?

View 2 Replies

.net - WPF DataGrid Scroll To Top After Sort?

Aug 24, 2011

I have a .Net 4.0 WPF application using a data grid. Currently after sorting by a column, the scroll position of the grid stays where it was before the sort.For this application, I need to scroll to the top of the grid after any sort.I've tried handling the sorting event like this

[code]...

But this appears to fire before the sorting takes place and doesn't perform the scroll.

View 2 Replies

Sort A Column In Datagrid

Sep 6, 2009

In my form I have several datagrids.

View 2 Replies

Forms :: Get DataGrid Sort Direction?

Apr 4, 2009

I know how to set sorting direction on each column in datagrid programatically, but I wonder how to do the opposite: obtain the sorting direction for a particular column.

View 1 Replies

VS 2008 How To Bubble Sort Datagrid

Mar 27, 2012

Dim cn As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database genk.mdb;")

[Code]...

I am trying to use bubble sort to sort to sort the deatils shown on the datagrid. The buuble sort code is there and the data grid view code is there which retrives the product details in my databse. How would i link the two together so that when the user clicks the button it uses the bubble sort code to sort and view the product deatils in order of the selected coulmn name selected by the user through a combo box?

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

Viewing Database Into DataGrid - Column Sort?

Mar 13, 2012

I have use this code to view my database into my datagird
Dim dbPath As String = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=../VG.mdb;Persist Security Info=False"
Dim dt As New DataTable
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("Select * from Marriage", dbPath)
ds.Tables.Add(dt)
da.Fill(dt)
Now every time I visit that form I have to manually click the column header of "EventDate" to that it will sort Descending. Is there a way to automatically sort it every time I visit this form?

View 2 Replies

VS 2010 Datagrid View Sort By Date?

Feb 7, 2012

I am using vb.net2010. (express)

I am currently writing a bit of software for myself and need guidance.

I have a datagridview on a form with a date column. (column0)

I am trying to sort this by date desending but it will only sort by the day (dd) and not the whole date (dd/mm/yyyy) which leaves the months and years unsorted.

(example of output):
#1 - 01/03/2012
#2 - 02/01/2010
#3 - 03/02/2011

[Code]....

I have been told " Make sure the Date column is a date type and not a string " which i have taken as the access database column type. I have set this as Date but it still won't sort the column in datagrid view by the whole date.

View 11 Replies

Sort Numbers From Lowest To Highest In Datagrid Table?

Mar 14, 2012

How to sort numbers from lowest to highest in my datagrid table?

View 1 Replies

How To Export Certain Columns From DataGrid

Nov 26, 2011

I have set up my connection to SQL Database.
Public Sub ConnectToSql()
Dim conn As New SqlClient.SqlConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
[Code] .....
How can I export specific columns from datagrid to specific SQL Table (and match up the columns (column names in datagrid are different to Column Names in SQL Table).

View 1 Replies

Datagrid With Columns Tha Have Different Datatable Rows?

Feb 9, 2010

i want to make a datagrid with 2 columns and many rows

the columns i want to have databinding with a datatable
i want the 1 row 1 column of datagrid have data from 1 row of datatable
i want the 1 row 2 column of datagrid have data from 2 row of datatable

[code].....

View 2 Replies

Got A Datagrid View With Two Check Box Columns In It?

Aug 22, 2011

Got a data grid view with two check box columns in it. Currently, got one set up and working how I want it using this

[Code]...

View 7 Replies

Increase The Width Of Columns Of A DataGrid In VB?

Sep 1, 2011

I am using DataGrid control in VB. I have created a DataTable at runtime and added 5 columns in this Datatable. I binded the data table with DataGrid control.

Width of DataGrid is 880. The default width of 5 columns of data table in DataGrid is 100. So for 5 columns width used = 500. So an empty space of 380 left at the right hand cornor of DataGrid. I want to fill this empty space with these 5 columns. I want to increase the width of columns so that it fully covered in DataGrid.

View 1 Replies

Place The Data Into The Datagrid's Columns

Apr 18, 2012

I'm in the process of converting an app to vb.net 2008. I was using an msflexgrid previously. I am not using a database to fill the datagrid but as the application recieves data via a tcp connection I place the data into the datagrid's columns. The problem I am having is with column widths. I found this code by doing a search on here and added to my form.

[Code]...

View 2 Replies







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