Solved

stop datagridview from sorting columns

Posted on 2011-03-17
3
756 Views
Last Modified: 2012-05-11
I have a datagridview and I set each column to be notSortable but when I run the appllication, you can sort the columns.  Then I read  where sorting has to be set in code when the data binding  is in code, but I don't know how to do this.  Can someone give me an example?  
Thanks
0
Comment
Question by:LenTompkins
  • 2
3 Comments
 

Author Comment

by:LenTompkins
ID: 35158078
I added this in my code after the data binding and it did not not work.

dgvCallingTime.Columns["DayofWeek"].SortMode = DataGridViewColumnSortMode.NotSortable;
0
 
LVL 4

Accepted Solution

by:
sgvill earned 500 total points
ID: 35158102
You might try something like this:
for (int i = 0; i < DataGridView.Columns.Count; i++)
 {
  DataGridView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  DataGridView.Columns[i].ReadOnly = true;
 }

Open in new window

0
 

Author Closing Comment

by:LenTompkins
ID: 35159445
Great it finally worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Image(7) 1 53
How to measure sizes and angles in scanned images ? 3 51
Search by two fields at the same time using c# radio button 5 37
Linq Help 1 34
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

937 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

11 Experts available now in Live!

Get 1:1 Help Now