473,804 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get a control from clipboard

I can use following codes to set and get object (serializable class)
from Clipboar

Clipboard.SetDa taObject(obj)

then

DataObject data=new DataObject()
obj=(ClassType) data.GetData(ty peof(ClassType) )

In the book Windows with C# (author Charles Petzold), it says a Button can be set or got from clipboard

I tried it. I can save it into clipboard. But after executing GetDate(); the obj is still null. In other word, I canno
get it from clipboard

Can you tell how to get a control or user control from clipboard

Thank

Keith
Nov 15 '05 #1
3 1722
Hi Keith.

The objects you want to retrieve from clipboard must be marked as serializable (this is a conclusion from my tests).

Sample code is:
[Serializable]
public class ABC
{
string s;
int i;
public ABC()
{
s="ABC";
i=1;
}
}
ABC obj = new ABC ();

Clipboard.SetDa taObject (obj);
obj = null;
obj = (ABC) Clipboard.GetDa taObject ().GetData (typeof (ABC));
Console.WriteLi ne (obj.ToString ());

and it works and retrives the custom class object from clipboard.

--
Cezary Nolewajka
mailto:c.****** *************** @no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"keith" <an*******@disc ussions.microso ft.com> wrote in message news:C0******** *************** ***********@mic rosoft.com...
I can use following codes to set and get object (serializable class)
from Clipboard

Clipboard.SetDa taObject(obj);

then

DataObject data=new DataObject();
obj=(ClassType) data.GetData(ty peof(ClassType) );

In the book Windows with C# (author Charles Petzold), it says a Button can be set or got from clipboard.

I tried it. I can save it into clipboard. But after executing GetDate(); the obj is still null. In other word, I cannot
get it from clipboard.

Can you tell how to get a control or user control from clipboard?

Thanks

Keith

Nov 15 '05 #2
Cezary

I knew it worked for serializable class because I had tried it.

My question was control, e.g. Button as following not user defined serializable clas

In the book WINDOWS WITH C# (author Charles Petzold), it says even a Button object ca
be set into and get from clipboard

I found out that I could set a Button object into clipboard because I checked it was in clipboard with

data.GetDataPre sent(typeof(But ton)

But when getting in from clipboard, it didn't work. No error message came out either

Do you know anything special to use clipboard with a control like Button

Thank
Keith
Nov 15 '05 #3
Can you post a sample project or a link to a project? Or send it zipped to
my email address (remove anti spams).

I shall play with it.

--
Cezary Nolewajka
mailto:c.****** *************** @no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply

"keith" <an*******@disc ussions.microso ft.com> wrote in message
news:E4******** *************** ***********@mic rosoft.com...
Cezary,

I knew it worked for serializable class because I had tried it.


[...]

Nov 15 '05 #4

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

Similar topics

8
11479
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a database, and I need the data to be laid out in a tabular format, and set out in a specific way. At the current point in time, I am copy/pasting the raw text from the database into a table layout in InDesign. What I was thinking is that if I could...
0
2129
by: TC | last post by:
Hello, Here is what I'm trying to do: -- Make sure both MS Excel and MS Word are running -- Create an Excel chart -- Save the Excel file -- Copy the Excel chart onto the clipboard using Ctrl + C -- Go to Word and look under Edit > Paste Special -- Note there is a source reference and an option to paste the chart as a
5
4080
by: TC | last post by:
Hello, Here is what I'm trying to do: -- Make sure both MS Excel and MS Word are running -- Create an Excel chart -- Save the Excel file -- Copy the Excel chart onto the clipboard using Ctrl + C -- Go to Word and look under Edit > Paste Special -- Note there is a source reference and an option to paste the chart as a
4
7432
by: Jason Sobell | last post by:
I'm trying to embed an image in an RTF control, but the only working method I can find is to do so via the clipboard and use myRTF.paste(). The problem here is that it obviously destroys the existing clipboard contents. Does anyone know if there is a way to call the RTF control directly (such as via API calls) and pass it the object to be inserted, or does anyone have any other suggestions? Cheers, Jason
2
2064
by: Ike | last post by:
In converting a VB6 app over to .NET, I encounter a particularly troublesome element regarding RichText. Private Sub mnuEditCopy_Click() Clipboard.SetText ActiveForm.rtfText.SelRTF End Sub Public datobj As New System.Windows.Forms.DataObject() Public Sub mnuEditCopy_Click(ByVal eventSender As System.Object, ByVal
0
1130
by: | last post by:
I'm trying to capture the rendered text in browser control (Without the HTML). One of the methods I tried was to send keys to the browser control - copy it to the clipboard and then get the text back from the clipboard. such as following: reports1._ReportBrowser.Select(); (Browser control)
4
1250
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to code an event and seem to be stuck on something that might seem pretty simple (I am a newbie...) I have two textboxes on a form, I have a button on a form that is supposed to copy selected text. When I click the button I want the selected text to be copied into the clipboard. I can do this by saying: Private Sub Copy_Click(ByVal sender As System.Object, ByVal e As
3
3062
by: Fritz Switzer | last post by:
I'm trying to AppendText to a TextEdit. I have a procedure that will go through the controls on a Windows form and return the control that has "focus". I have a number of TextEdits on my form and don't know which control has focus. I then want to paste text from the ClipBoard to this TextEdit control. The following code is what I'm using. Everything works fine, it identifies the correct control,
2
3333
by: crapycoder | last post by:
hi all, please help....!! i have added a kodak image edit control on my form. when i click get image button, "abc.img" will be displayed. i have a button named "copy to clipboard". when i click it, i want the image in kodak image edit control to be copied to clipboard.
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.