?
Solved

Sorting in DataGridView

Posted on 2010-01-12
6
Medium Priority
?
267 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
  • 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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

621 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