Solved

Activate DataGrid column pragmatically

Posted on 2004-09-06
2
222 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
Comment Utility
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
Comment Utility
Thank you. That works well.

Thank you for your time,
Arrummzen
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

17 Experts available now in Live!

Get 1:1 Help Now