Hi everyone,
this is another thread about how to sort the Datagridview. In my scenario I've a datagridview and this is the code I use to fill it:
vb Code:
  1. ...declaration of cmdStoredProc...
  2.         cn.Open()
  3.         cmdStoredProc.ExecuteNonQuery()
  4.  
  5.     Dim da As OracleDataAdapter = New OracleDataAdapter(cmdStoredProc)
  6.     Dim ds As DataSet = New DataSet
  7.     da.Fill(ds, cNomeSP)
  8.     MyFillDGV(dgvGriglia, ds)
  9.     cn.Close()
and then, this is MyFillDGV:

vb Code:
  1. dgvGriglia.AutoGenerateColumns = False
  2.     dgvGriglia.AllowUserToAddRows = False
  3.     dgvGriglia.AllowUserToDeleteRows = False
  4.     dgvGriglia.AllowUserToResizeRows = False
  5.     dgvGriglia.AllowUserToOrderColumns = True
  6.     dgvGriglia.MultiSelect = False
  7.     dgvGriglia.ReadOnly = True
  8.     dgvGriglia.RowHeadersVisible = False
  9.     dgvGriglia.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing
  10.     dgvGriglia.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  11.  
  12.     Dim oCol As New DataGridViewTextBoxColumn
  13.     oCol.Name = cColName
  14.     oCol.DefaultCellStyle.Alignment = oAlignment
  15.     oCol.Width = VB6.TwipsToPixelsX(nTwWidth)
  16.     oCol.HeaderText = cHeaderText
  17.     oCol.DataPropertyName = cDataPropertyName
  18.     dgvGriglia.columns.add(oCol)
  19.     dgvGriglia.Columns(0).SortMode = DataGridViewColumnSortMode.Automatic
  20.  
  21.     dgvGriglia.DataSource = ds.Tables(0).Select(cFilter)

So it works very well only if i set AutoGenerateColumns = True.
Why this code doesn't work with the autogeneratecolumns property set to false and the runtime binding of each column?
Thank you in advance for your reply.

Best regards