?
Solved

Sorting in DataGridView

Posted on 2010-01-12
6
Medium Priority
?
265 Views
Last Modified: 2013-12-17
Hi

i am binding ListDatasource to datagridview as follows.

List<Request> lstRequests = new List<Request>
lstRequests. AddRange(m_oRequests.Cast<Request>());
dgv_requests.DataSource = lstRequests;

How apply sorting on the datagridview.

Thanks,
Shashi

0
Comment
Question by:shore-support
[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
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 26300251
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 26300571
The question is not very clear - what's the problem?

Did you try DataGridView.Sort method?

Check details here:

http://msdn.microsoft.com/en-us/library/0868ft3z.aspx
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 26300589
0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 

Author Comment

by:shore-support
ID: 26302597
Hi,
none of the aboc=ve comments are useful for me.

can any give the code for sorting winforms datagidview.

DataSource  to my DataGridView is List<object> or IBincingList<object>

thanks,
Shashi
0
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 1500 total points
ID: 26307791
Shashi, I believe above links might be useful - the question is how to apply. Ind you need to realize yourself what do you need.

What is sorting? You compare objects of some specific type and put them in some specific order.
If you have (as from you last post) a list of objects (List<object>) how you think you may sort them? Ther is no Compare method for <object> type. Therefore we can't talk about sorting at all. If we sort strings we compare characters inside the strings, if we sort numbers - we compare numbers. But how you want to sort generic objects.
Therefore, you need objects of some specific type. These objects need to have Compare method. Then you  can use approaches listed above.

By the way, the List class has the Sort method, you may use it before making the list a DataSource. But again - objects have to be comparable.
0
 

Author Closing Comment

by:shore-support
ID: 31676093
ab
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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