Solved

stop datagridview from sorting columns

Posted on 2011-03-17
3
762 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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