c# - Copy Searched Rows from DataGridView to Another DataGridView -


How can we copy one or more rows from another data grid view to another data grid view? In the same form here, I am looking for options that first searches from the grid and if you get some matching rows, then copy them to another grid. How can I get it?

You can do something like this:

  ConvertGridToTable (); // Add Data to Datacat from Gridview Clipboard. Clear (); Data Object Data = New Data Object (Data Format. Serials, DATAntended); MessageBox.Show ("data is copied."); Clipboard.SetDataObject (data);   

is now available in the Dataeted clipboard, which you can paste into another gridview that you can do with it:

  DataObject data = (DataObject ) Clipboard .GetDataObject (); DataTable DT = (DataTable) data GateData (DataFormats. Serialable); Foreign Currency (dt.Rows in Detroe Dr) {dtData.ImportRow (dr); } DtData.AcceptChanges (); GrdProgram Data.DataSource = dtData; MessageBox.Show ("Data Paste."); For  one or more rows  you can get it with looping through the selected rows.   

Edit:

/ P>

Edit

This convertor is content in the TTOTABLE

  Private Zero Convert GridTable () {if (Datatabledt.Rows.Count & Gt; 0) {} Datasetect = dtData.Clone (); Foreign exchange (Datagram WyverRRR gr in your gradew. Selected light) {Detarauve DC = DataSetrated.NewRow (); DC ["key-field"] = Int32.Parse (gr.Cells [0] .Value.ToString ()); ..... Datatatted.day.ed (DC); } Data-statenced. Accept change (); }    

Comments