Skip to content
Loading
+3
  • Darshan Shah
    +1
    1. foreach (DataGridViewColumn column in dataGridView.Columns)  
    2. {  
    3.     column.SortMode = DataGridViewColumnSortMode.NotSortable;  
    4. }  
    Hope this make sense!
    +1
  • Sonu Gupta
    +1
    Hi use below code snippet :
     
    private void gdvSort_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
    {
    for (int i = 0; i < gdvSort.Columns.Count; i++)
    {
    gdvSort.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
    }
    }
     
    Using Linq :
    gdvSort.Columns.Cast().ToList().ForEach(f => f.SortMode = DataGridViewColumnSortMode.NotSortable);
    +1
  • Amit Gupta
    +1
    @Members
     
    Its worthless to post the same answers, instead you can upvote the answer dispite cluttering it 
    +1
  • Rajanikant Hawaldar
    +1
    Agree with @Amit Gupta
    +1
  • +1
    Thank you amit sir and all
    +1