title: How to sort depends on Particular Column In Datagridview?
body: <p>if grid like this</p>
  
  <pre><code>     Name     Age
  
       Raj      20
       Biny     19
       Raj      17
       Jose     27
       Jose     15
  </code></pre>
  
  <p>now am click Name Grid Column Means</p>
  
  <p>I want output like below   </p>
  
  <pre><code>       Name     Age
  
        Biny     19        
        Jose     15
        Jose     27
        Raj      17
        Raj      20
  
   See above table sort Based on Name column
  </code></pre>
  
  <p>Eg:-
  now jose age also sort like 15,27</p>
  
  <p>am using below code but it does'nt work properly
   private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)</p>
  
  <p>{
              var sortGlyph = dataGridView1.Columns["Name"].HeaderCell.SortGlyphDirection;</p>
  
  <pre><code>        switch (sortGlyph)
          {
              case SortOrder.None:
              case SortOrder.Ascending:
                       dataGridView1.Sort(dataGridView1.Columns["Name"], ListSortDirection.Descending);
  
                  dataGridView1.Columns["Name"].HeaderCell.SortGlyphDirection = SortOrder.Descending;
                  break;
              case SortOrder.Descending:
                                     dataGridView1.Sort(dataGridView1.Columns["Name"], ListSortDirection.Ascending);
                  dataGridView1.Columns["Name"].HeaderCell.SortGlyphDirection = SortOrder.Ascending;
                  break;
          }
  </code></pre>
  
  <p>}</p>
  
  <p>Below Code is Answer For Above Question</p>
  
  <pre><code>       switch (sortGlyph)
          {
              case SortOrder.None:
              case SortOrder.Ascending:
                  dt.DefaultView.Sort = "Name,Age";
                  dt = dt.DefaultView.ToTable();
                  dataGridView1.DataSource = dt;
  
                  dataGridView1.Columns["Name"].HeaderCell.SortGlyphDirection     =SortOrder.Descending;
                  break;
              case SortOrder.Descending:
                                      dt.DefaultView.Sort = "Name,Age";
                                      dt = dt.DefaultView.ToTable();
                                      dataGridView1.DataSource = dt;
                                      dataGridView1.Columns["Name"].HeaderCell.SortGlyphDirection = SortOrder.Ascending;
                  break;
          }
  </code></pre>