Solved

Activate DataGrid column pragmatically

Posted on 2004-09-06
2
223 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now