locked
Disabling sort function in Datagridview RRS feed

  • Question

  • Hi

    Is it possible to disable the "sort function" in datagridview that happens when pressing the header?

    I would like display some data that you cant order by clicking on the columheader. Can you lock the headers somehow?

    Tuesday, May 16, 2006 12:11 AM

Answers

  • If i recall correctly - if you go into the column individual column definitions and look at there properties

    Select datagrid -Right Click and select Edit Column -> Sort Mode properties 

    Set it to Not Sortable.

    This enables you to select which columns you want to allow to be sortable and which ones you dont.

    Tuesday, May 16, 2006 12:34 AM

All replies

  • If i recall correctly - if you go into the column individual column definitions and look at there properties

    Select datagrid -Right Click and select Edit Column -> Sort Mode properties 

    Set it to Not Sortable.

    This enables you to select which columns you want to allow to be sortable and which ones you dont.

    Tuesday, May 16, 2006 12:34 AM
  • Ok, i hadn't seen that funktion..

    I forgot to mentation that i use a dataadapter to fill the grid but i found out that you could set the sortfunction in the code as well..

    Thanx for the help....

    If others read this tread and would like to know the code for setting it, it could be something like:

    DataGridview1.Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable

    Tuesday, May 16, 2006 12:23 PM
  • i dont want any column to get sorted .

    But I am desktop application user and i don't get any such property in datagridview.

    If u can please help me.

    Thursday, February 8, 2007 12:48 PM
  • Hello

     

    Take care !

     

    It does'nt work too ..

     

    I'm still trying to find out how to disable the automatic sort !!

     

    Sunday, March 23, 2008 7:45 AM
  •  for (int i = 0; i < DataGridView.Columns.Count; i++)
     {
      DataGridView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
      DataGridView.Columns[i].ReadOnly = true;
     }
    Thursday, February 18, 2010 2:09 PM