Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Activate DataGrid column pragmatically

Posted on 2004-09-06
2
Medium Priority
?
230 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 600 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

609 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