System.Data.DataTable.Copy C# (CSharp) Method

Copy() public method

public Copy ( ) : DataTable
return DataTable
        public DataTable Copy()
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Copy|API> {0}", ObjectID);
            try
            {
                DataTable destTable = Clone();

                foreach (DataRow row in Rows)
                {
                    CopyRow(destTable, row);
                }

                return destTable;
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Usage Example

Example #1
0
        public void FormatDataGridView()
        {
            DataTable dt = new DataTable();


            dt = NewDataTable(applicationFileName, ",", true);
            if (applicationFileName.Contains("OPS"))
            {
                dataGridView2.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
            else if (applicationFileName.Contains("DPM"))
            {
                dataGridView1.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
            else if (applicationFileName.Contains("BDW"))
            {
                dataGridView3.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
            else if (applicationFileName.Contains("DEALS"))
            {
                dataGridView4.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
        }
All Usage Examples Of System.Data.DataTable::Copy
DataTable