Solved

Activate DataGrid column pragmatically

Posted on 2004-09-06
2
226 Views
Last Modified: 2010-08-05
I am using a DataGrid control in a C# application. When I use my mouse to click on a DataGrid column header, a little arrow (up/down) appears in the column header and records are sorted. I need the same thing to happen automatically, without any user intervention. How do I do this?

Thank you for your time,
Arrummzen
0
Comment
Question by:Arrummzen
2 Comments
 
LVL 20

Accepted Solution

by:
TheAvenger earned 200 total points
ID: 11987673
You need to use the DataView.Sort property (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataViewClassSortTopic.asp).

If you are using a DataView for the DataSource of the DataGrid, just set its Sort property to the correct column you need to sort by. If you are using a DataTable for the DataSource of the DataGrid, you can use the DataTable.DefaultView property to get the data view and then set the Sort property.
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 11987750
Thank you. That works well.

Thank you for your time,
Arrummzen
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question