Link to home
Start Free TrialLog in
Avatar of nvms
nvms

asked on

TextBox.Copy() to Clipboard in C# Compact Framework ?

Hi

I am finding more and more aspects of the .NET Compact Framework lacking the full framework. From what I can see I cannot copy text selections to the clipboard ? Does anyone know if this is just a "wait for Service Pack 2" issue or if I am not Using xxxx; the right resources.

Thanks

Stu
Avatar of DaniPro
DaniPro
Flag of Italy image

You can use the Clipboard class:

private void button1_Click(object sender, System.EventArgs e) {
    // Takes the selected text from a text box and puts it on the clipboard.
    if(textBox1.SelectedText != "")
       Clipboard.SetDataObject(textBox1.SelectedText, true);
    else
       textBox2.Text = "No text selected in textBox1";
 }
Avatar of nvms
nvms

ASKER

Hi thanks for the comments, this of course works fine in a Windows project but in a Mobile Device project (using the Compact .NET Framework) the following error is generated on deployment:

C:\Documents and Settings\My Documents\Files\CODE\C#.NET Examples\Clipboard Handling\Copy\Form1.cs(93): The type or namespace name 'Clipboard' could not be found (are you missing a using directive or an assembly reference?)

Code is OK from your example with the following references:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.IO;

My problem remains, the CF does not support the clipboard
ASKER CERTIFIED SOLUTION
Avatar of DaniPro
DaniPro
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nvms

ASKER

Already tried as have all the other standard clipboard commands, retults in:

C:\Documents and Settings\Files\CODE\C#.NET Examples\Clipboard Handling\Copy\Form1.cs(98): 'System.Windows.Forms.TextBox' does not contain a definition for 'Copy'

If you start a new .NET project and choose a Smart Device Application using the Emulator you will see the problem
Avatar of nvms

ASKER

Please note THERE IS NO SOLUTION ON THIS PAGE !!! I have awarded the points as thanks for contributing but as you know having found this, the .NET Compact Framework is rather 'cut-down'. The functions suggested will not work. Open to further discussion on this topic.
look at this page:

http://www.opennetcf.org/forms.asp  this is an open source libary which provides the needed feature