|
-
Jul 18th, 2003, 02:17 AM
#1
Thread Starter
New Member
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
-
Jul 18th, 2003, 03:28 AM
#2
You shouldn't need that DSCopy class try this:
VB 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")
Clipboard.SetDataObject(ds)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim c As IDataObject = Clipboard.GetDataObject
Dim ds As DataSet = c.GetData(GetType(DataSet))
MsgBox(ds.Tables.Count)
End Sub
-
Jul 18th, 2003, 03:33 AM
#3
Thread Starter
New Member
What i need is a way to place and read datarow(s) to clipboard. I can place and read dataset but for some "unknown" reason i cannot do the same for datarow. someone recomended me to use a serializable class to do do this i've tryed but it still does not work.
-
Jul 18th, 2003, 09:35 AM
#4
Why just the datarows? Just use the dataset and then only get the rows. A datarow without at least a table isn't all that useful anyway.
Last edited by Edneeis; Jul 18th, 2003 at 09:38 AM.
-
Jul 19th, 2003, 03:38 AM
#5
Thread Starter
New Member
I need to be able to read information that datarow holds in another instance of my application for example.
I have datasets that share the same schemas but not the same data and i want to be able to cut/copy information from one application to another, or even as a new instance into the same application without having to create a string that gives me an indication about table and data the copied row contains.
"Table1?John~Smith~1977" etc.
I just want to know why can't i do it the way i supposed to be able to do it...
Thanks
-
Nov 22nd, 2005, 04:11 AM
#6
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|