Solved

stop datagridview from sorting columns

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

757 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

24 Experts available now in Live!

Get 1:1 Help Now