Пример #1
0
 public virtual void AddRow(IDataRow row)
 {
     try
     {
         if (m_grid.InvokeRequired)
         {
             m_form.Invoke(new AddGridRowHandler(AddRow), row);                          // check if we need to invoke the delegate
         }
         else
         {
             // delegate not required, just add row to the grid
             if (row.Key != null)
             {
                 string[] cellValues = row.GetCells();
                 cellValues[0]         = row.Key;
                 m_rowIndexes[row.Key] = m_grid.Rows.Count;
                 m_grid.Rows.Add(cellValues);
             }
         }
     }
     catch (ObjectDisposedException) { }         // The object went away; ignore it since we're probably exiting
 }
Пример #2
0
 public virtual void UpdateRow(IDataRow row)
 {
     try
     {
         if (m_grid.InvokeRequired)
         {
             m_form.Invoke(new UpdateGridRowHandler(UpdateRow), row);                        // check if we need to invoke the delegate
         }
         else
         {
             // delegate not required, just update the grid row
             if (m_rowIndexes.ContainsKey(row.Key))
             {
                 string[] cellValues = row.GetCells();
                 cellValues[0] = row.Key;
                 int             ri = m_rowIndexes[row.Key];
                 DataGridViewRow gr = m_grid.Rows[ri];
                 gr.SetValues(cellValues);
             }
         }
     }
     catch (ObjectDisposedException) { }         // The object went away; ignore it since we're probably exiting
 }
Пример #3
0
 public void UpdateRowAtIndex(int ix, IDataRow row)
 {
     try
     {
         // check if we need to invoke the delegate
         if (m_grid.InvokeRequired)
         {
             // call this function again using a delegate
             m_form.Invoke(new Action <int, IDataRow>(UpdateRowAtIndex), ix, row);
         }
         else
         {
             // delegate not required, just update the grid row
             string[]        cellValues = row.GetCells();
             DataGridViewRow gr         = m_grid.Rows[ix];
             gr.SetValues(cellValues);
         }
     }
     catch (ObjectDisposedException)
     {
         // The list view object went away, ignore it since we're probably exiting.
     }
 }
Пример #4
0
        /*public void UpdatePrices(List<IDataRow> updateList)
         * {
         *  foreach (var item in updateList)
         *  {
         *      bool found = false;
         *      foreach (DataGridViewRow row in m_grid.Rows)
         *      {
         *          if (row.Cells[0].Value.ToString() == item.Key)
         *          {
         *              string[] cellValues = item.GetCells();
         *              row.SetValues(cellValues);
         *              found = true;
         *              break;
         *          }
         *      }
         *      if (found == false)
         *      {
         *          string[] cellValues = item.GetCells();
         *          m_grid.Rows.Add(cellValues);
         *      }
         *  }
         * }*/

        public void AddRow(IDataRow row)
        {
            try
            {
                // check if we need to invoke the delegate
                if (m_grid.InvokeRequired)
                {
                    // call this function again using a delegate
                    //m_form.Invoke(new AddGridRowHandler(AddRow), row);
                    m_form.Invoke(new Action <IDataRow>(AddRow), row);
                }
                else
                {
                    // delegate not required, just add row to the grid
                    string[] cellValues = row.GetCells();
                    m_rowIndexes[row.Key] = m_grid.Rows.Count;
                    m_grid.Rows.Add(cellValues);
                }
            }
            catch (ObjectDisposedException)
            {
                // The list view object went away, ignore it since we're probably exiting.
            }
        }