Home - Forums-.NET - FlyGrid.Net (Windows Forms) - effeciency question

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

effeciency question
Link Posted: 14-Sep-2005 04:17
Hi,
When I delete a row from my datatable that my grid is bound to, the row in the grid still appears. So that the grid is refreshed I do the following:

      
  
        m_dsDetail = m_fields.GetDetailCtrl
        PrepareDetailColumns()
        dgDetail.Rows.DataMember = m_dsDetail.Tables(0).TableName
        dgDetail.Rows.DataSource = m_dsDetail
        dgDetail_NodeSelectedChanging(Nothing, Nothing)
        dgDetail_NodeSelectedChange(Nothing, Nothing)


so basically i'm refreshing the whole grid after I refreshed my dataset. Is there a more efficient way to do this ? (I've tried m_dsDetail.AcceptChanges but it wouldn't do)

Thanks
Link Posted: 14-Sep-2005 12:38
Why you not use FlyGrid's navigation bar Delete button to delete rows?
If you want to delete row from code, please use following effecient code to delete row:
[C#]
private void DeleteCurrentRow(FlyGrid flyGrid)
{
  int currentRow = -1;
  try
  {
    flyGrid.BeginInit();
    try
    {
      NodeBase node = flyGrid.Selected;
      if (node != null)
      {
        currentRow = node.Index;
        DataRowView dr = node.Value as DataRowView;
        dr.Delete();
      }
    }
    finally
    {
      flyGrid.EndInit();  
    }
  }
  finally
  {
    //focus new node
    int newFocused = currentRow != -1 && currentRow < flyGrid.ActivePort.RowCount ? currentRow : flyGrid.ActivePort.RowCount - 1;
    flyGrid.Selected = flyGrid.ActivePort.Rows.Items[newFocused];
  }
}

Link Posted: 19-Sep-2005 02:34
Thanks a lot for your help