Datarows and clipboard ...
Hi All,
I'm trying to place datarow in clipboard but whenever i attempt to read it i get nothing, although the object is there...
I do it the following way:
Code:
<Serializable()> Public NotInheritable Class DSCopy
Public drs As DataRow
Public ds As DataSet
Public Sub New(ByVal dss As DataSet)
ds = dss
End Sub
Public Function Add(ByVal Item As DataRow)
drs = Item
End Function
End Class
And the code is the following :
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ds = New DataSet
ds.ReadXmlSchema("C:\WSOS\Code\POCode\OntoExplorer\bin\ModelDSScheme.xml")
ds.ReadXml("C:\Documents and Settings\Ontos AG\Light Ontos\ModelDS.mds")
Dim c As New DSCopy(ds)
c.Add(ds.Tables(0).Rows(0))
Clipboard.SetDataObject(c)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim c As DSCopy
Dim myDataObject As IDataObject = Clipboard.GetDataObject()
Debug.Write(myDataObject.GetFormats)
Dim PastedSubObject As DSCopy
If (myDataObject.GetDataPresent(GetType(DSCopy))) Then
c = myDataObject.GetData(GetType(DSCopy))
End If
End Sub
where Button1 writes to clipboard and button2 attempts to read from it. What i don't understand is if i exclude a line of code that does 'c.Add(ds.Tables(0).Rows(0))' from button1 everything works fine and button2 returns a correct object otherwise it returns nothing.
Could someone please explain to me why is this not working.
Many thanks
Re: Datarows and clipboard ...
http://www.vbforums.com/newreply.php...p=2236380#wave
i had the same problem and i found this page
http://www.firelightsoftware.com/CopyPasteDataset.aspx
sounds logical ... or???
... you can only copy seriazible objects to clipboard... so put the rows in a dataset and copy the dataset to clipboard