Solved

Activate DataGrid column pragmatically

Posted on 2004-09-06
2
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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