Thursday 15 April 2010

c# - How to get the changed cells or added rows after Datagridview Sort -


I follows a DataGridView with data source:

  bindingSource = DataTable dataGridView.DataSource = bindingSource   

editing cells or add new rows I apply a different formatting style, if I lose DataGridView click Sort header formatting style on one of the columns So my question is:

After sorting the datagridware, how do I know which cell I have been added or added?, Then I can apply the formatting style again.

VB.NET or C # is OK

I changed Selvol the string / Bdlunga event, sample:

  private sub DataGridView_CellValueChanged (as System.Object in, manages) DataGridView.CellValueChanged e DataGridViewCellEventArgs e.RowIndex = -1 or IsNothing (DataGridView.CurrentCell) then return end so as dim cellPosition Short = DataGridView.CurrentCell.ColumnIndex dim styles (25) String dim styles as Cell = DataGridView.Rows (e.RowIndex) .cs ("CellStyleDescriptor"). If not IsDBNull value (stylesCell) and _ IsNothing not (stylesCell) then Styles = Split (stylesCell, ",") End If IsDBNull (DataGridView.Rows (e.RowIndex) .Cells ( "ID"). Value) then integer as I to = 0 "25 is the new road added Styles (i) =" N "Next Otherwise Styles (cellPosition) = 'e' to edit / modify cell terminated DataGridView.Rows (e.RowIndex ) .cs ("CellStyleDescriptor"). Value = String.Join ( ",", String) closing sub   

Apply reading styles Selformeting events / sample:

No comments:

Post a Comment