Solved

stop datagridview from sorting columns

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

636 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