473,378 Members | 1,156 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Custom format on Clipboard

I am trying to Copy and paste using a custom format but I canot retrieve the
data.
In the main Form's class I have declared:

Dim myDocmanFormat as DataFormats.Format

then in the New Sub of the main form I have:

myDocmanFormat = DataFormats.GetFormat("DocmanFormat")

In the Copy sub I have:

Dim thisDataObject As New DataObject
Dim thisData As DocmanData = CType(thisNode.Tag, DocmanData).Clone
thisDataObject.SetData(Me.myDocmanFormat.Name, thisData)
Clipboard.SetDataObject(thisDataObject, True)

When I step through this part of the Copy routine "thisData" is definately
not Nothing. In the watch window I can access all of the properties of
"thisData".
In the Paste routine I have:

If Clipboard.GetDataObject.GetDataPresent(Me.myDocman Format.Name) Then
Dim myClipData As IDataObject = Clipboard.GetDataObject()
Dim DataFromClip As DocmanData =
CType(myClipData.GetData(Me.myDocmanFormat.Name), DocmanData)

Although the data format is present it always returns Nothing, that is
"DataFromClip" remains Nothing after executing the last line.

Can someone please tell me what I have done wrong.

Thanks,
Fred
Nov 20 '05 #1
2 3830
Hi Fred,

I don't see anything obviously wrong. You need to make sure the class
DocmanData is serializable. Here's some sample test code I threw together
that seems to work.

<Serializable()> _
Public Class TestObject

Private m_Value As String

Public Sub New(ByVal testValue As String)
m_Value = testValue
End Sub
Public Property TestValue() As String
Get
Return m_Value
End Get
Set(ByVal Value As String)
m_Value = Value
End Set
End Property
End Class

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
Private Sub buttonCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles buttonCopy.Click
Dim test As New TestObject("Hello, this is a test.")
Dim testFormat As DataFormats.Format =
DataFormats.GetFormat("MyTestFormat")
Dim dataObj As New DataObject
dataObj.SetData(testFormat.Name, False, test)
Clipboard.SetDataObject(dataObj)
End Sub

Private Sub buttonShow_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles buttonShow.Click
Dim dataObj As DataObject = Clipboard.GetDataObject()
Dim testFormat As DataFormats.Format =
DataFormats.GetFormat("MyTestFormat")
If dataObj.GetDataPresent(testFormat.Name, False) Then
Dim test As TestObject =
CType(dataObj.GetData(testFormat.Name), TestObject)
MsgBox(test.TestValue)
Else
MsgBox("No data present")
End If
End Sub
End Class

Perhaps you can use this to see what's different in your case.

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: "fred" <fr**@NoSpam.com>
Subject: Custom format on Clipboard
Date: Mon, 12 Apr 2004 21:56:09 +1200
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#i**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 219-88-118-13.dialup.xtra.co.nz 219.88.118.13
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP11.phx.gblXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:194669
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I am trying to Copy and paste using a custom format but I canot retrieve thedata.
In the main Form's class I have declared:

Dim myDocmanFormat as DataFormats.Format

then in the New Sub of the main form I have:

myDocmanFormat = DataFormats.GetFormat("DocmanFormat")

In the Copy sub I have:

Dim thisDataObject As New DataObject
Dim thisData As DocmanData = CType(thisNode.Tag, DocmanData).Clone
thisDataObject.SetData(Me.myDocmanFormat.Name, thisData)
Clipboard.SetDataObject(thisDataObject, True)

When I step through this part of the Copy routine "thisData" is definately
not Nothing. In the watch window I can access all of the properties of
"thisData".
In the Paste routine I have:

If Clipboard.GetDataObject.GetDataPresent(Me.myDocman Format.Name) Then
Dim myClipData As IDataObject = Clipboard.GetDataObject()
Dim DataFromClip As DocmanData =
CType(myClipData.GetData(Me.myDocmanFormat.Name ), DocmanData)

Although the data format is present it always returns Nothing, that is
"DataFromClip" remains Nothing after executing the last line.

Can someone please tell me what I have done wrong.

Thanks,
Fred



Nov 20 '05 #2
Thanks Craig, the <Serializable()> attribute seems to have fixed the
problem.

Fred

"Craig Vick [MSFT]" <cr*****@online.microsoft.com> wrote in message
news:6y**************@cpmsftngxa10.phx.gbl...
Hi Fred,

I don't see anything obviously wrong. You need to make sure the class
DocmanData is serializable. Here's some sample test code I threw together
that seems to work.

<Serializable()> _
Public Class TestObject

Private m_Value As String

Public Sub New(ByVal testValue As String)
m_Value = testValue
End Sub
Public Property TestValue() As String
Get
Return m_Value
End Get
Set(ByVal Value As String)
m_Value = Value
End Set
End Property
End Class

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
Private Sub buttonCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles buttonCopy.Click
Dim test As New TestObject("Hello, this is a test.")
Dim testFormat As DataFormats.Format =
DataFormats.GetFormat("MyTestFormat")
Dim dataObj As New DataObject
dataObj.SetData(testFormat.Name, False, test)
Clipboard.SetDataObject(dataObj)
End Sub

Private Sub buttonShow_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles buttonShow.Click
Dim dataObj As DataObject = Clipboard.GetDataObject()
Dim testFormat As DataFormats.Format =
DataFormats.GetFormat("MyTestFormat")
If dataObj.GetDataPresent(testFormat.Name, False) Then
Dim test As TestObject =
CType(dataObj.GetData(testFormat.Name), TestObject)
MsgBox(test.TestValue)
Else
MsgBox("No data present")
End If
End Sub
End Class

Perhaps you can use this to see what's different in your case.

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: "fred" <fr**@NoSpam.com>
Subject: Custom format on Clipboard
Date: Mon, 12 Apr 2004 21:56:09 +1200
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#i**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 219-88-118-13.dialup.xtra.co.nz 219.88.118.13
Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0 8.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:194669
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I am trying to Copy and paste using a custom format but I canot retrieve

the
data.
In the main Form's class I have declared:

Dim myDocmanFormat as DataFormats.Format

then in the New Sub of the main form I have:

myDocmanFormat = DataFormats.GetFormat("DocmanFormat")

In the Copy sub I have:

Dim thisDataObject As New DataObject
Dim thisData As DocmanData = CType(thisNode.Tag, DocmanData).Clone
thisDataObject.SetData(Me.myDocmanFormat.Name, thisData)
Clipboard.SetDataObject(thisDataObject, True)

When I step through this part of the Copy routine "thisData" is definatelynot Nothing. In the watch window I can access all of the properties of
"thisData".
In the Paste routine I have:

If Clipboard.GetDataObject.GetDataPresent(Me.myDocman Format.Name) Then Dim myClipData As IDataObject = Clipboard.GetDataObject()
Dim DataFromClip As DocmanData =
CType(myClipData.GetData(Me.myDocmanFormat.Name ), DocmanData)

Although the data format is present it always returns Nothing, that is
"DataFromClip" remains Nothing after executing the last line.

Can someone please tell me what I have done wrong.

Thanks,
Fred


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: BC | last post by:
Hello, We are creating an Office add-in. We are able to display the add-in successfully. However, we followed a sample program, and it displays a FaceID = 1044 (which is not the bitmap of the...
0
by: MacDk | last post by:
Hi, I need to paste some text to users clipboard from an ASP.NET-page. This can be done by DHTML, but the trick is that the text must by pasted as HTML not pure text. Cant figure out how to do...
0
by: fred | last post by:
I am trying to Copy and paste using a custom format but I canot retrieve the data. In the main Form's class I have declared: Dim myDocmanFormat as DataFormats.Format then in the New Sub of...
11
by: nAmYzArC | last post by:
Hi all, On our site we have a section that allows users to copy and paste or drag and drop the contents of (pretty much any) webpage into a Div. I need to get access to the clipboard data. To do...
7
PEB
by: PEB | last post by:
Hi, I've managed to copy an image to the clipboard from other application different from Access, but i want to get the image in the clipboard and save it in tif format using Access... Somewhere...
6
dima69
by: dima69 | last post by:
Biff format is defined as default format for copying data from Access to Excel (under registry key ...\Access\Clipboard Formats). This format has a known problem as numbers are pasted as text using...
1
by: chris | last post by:
I'm not sure this is even feasible. What I want to do is create a command button. When this command button is pressed, it taes field values and puts them into text format. I think I know how to...
0
by: pnarasimha | last post by:
Hai Friends , I have strucked with one problem in my Project , that is actually in my Project i had Grid control and User may Copy excel data from Excel file rows and paste into in...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I created a basic class library (dll, tlb) in VB2005 for com use in MS Access. I added a form to the class library because eventually, I want to use a SaveDialog control with this dll. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.