Results 1 to 6 of 6

Thread: Datarows and clipboard ...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    11

    Question 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

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You shouldn't need that DSCopy class try this:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         ds = New DataSet
    3.         ds.ReadXmlSchema("C:\WSOS\Code\POCode\OntoExplorer\bin\ModelDSScheme.xml")
    4.         ds.ReadXml("C:\Documents and Settings\Ontos AG\Light Ontos\ModelDS.mds")
    5.         Clipboard.SetDataObject(ds)
    6.     End Sub
    7.  
    8.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    9.         Dim c As IDataObject = Clipboard.GetDataObject
    10.         Dim ds As DataSet = c.GetData(GetType(DataSet))
    11.         MsgBox(ds.Tables.Count)
    12.     End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    11
    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.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    11
    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

  6. #6
    New Member
    Join Date
    Nov 2005
    Posts
    7

    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
  •  



Click Here to Expand Forum to Full Width