Solved

stop datagridview from sorting columns

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF user control poped up from a window 1 51
"The resource cannot be found" 1 43
ASP.NET data base connection 35 95
C# rename a class and update all references efficiently 6 53
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

739 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