paste datagrid rows

DavidT_macktool

Well-known member
Joined
Oct 21, 2004
Messages
502
Location
Indiana
Programming Experience
3-5
I want to copy several rows from the details datagrid and paste them into the same grid for a different part number.

I can select the rows and copy them to the clipboard, I can paste them into Excel, but my knowledge of the clipboard class is limited.

How do I format the clipboard so I can paste it into a grid?
System.Windows.Forms.Clipboard.SetDataObject(DataFormats.CommaSeparatedValue) is what I use to get it into an Excel format.

here is the code for adding a row to the table I want to paste into:

Dim prompt AsString
Dim qty, idetnumber AsInteger
qty = 1
Me.BindingContext(DsDetail1, "Detail").Position = (DsDetail1.Tables("Detail").Rows.Count - 1)
Try
idetnumber = DetailGrid.Columns("detail number").Value + 1
Catch ex As Exception
idetnumber = 1
EndTry
Try
Me.BindingContext(DsDetail1, "Detail").EndCurrentEdit()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
EndTry
Dim tblDetail As DataTable
tblDetail = DsDetail1.Tables("Detail")
Dim tblPartDet As DataTable
tblPartDet = DsPartDetail1.Tables("Part")
Dim drCurrentdet As DataRow
Dim drCurrentpartdet As DataRow
drCurrentdet = tblDetail.NewRow()
' Set the DataRow field values as necessary.
drCurrentdet("assy Part ID") = iCurrentPartid
drCurrentdet("detail number") = idetnumber
drCurrentdet("detail part id") = PartDetailGrid.Columns("part id").Value
drCurrentdet("part number") = PartDetailGrid.Columns("part number").Value
drCurrentdet("qty per assy") = qty
drCurrentdet("Report") =
True
tblDetail.Rows.Add(drCurrentdet)


how do I call the paste that will add the copied rows in the same manner?
There is a good example of how to get Excel data into an unbound datagrid but my datagrid is bound to a dataset.
See http://www.codeguru.com/vb/controls/vbnet_controls/datagridcontrol/article.php/c6393/
Using this example i guess i could load a dummy grid and add the data from it. There has got to be a better way...
Any Ideas/examples?
 
Top Bottom