?
Solved

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

Posted on 2003-11-19
6
Medium Priority
?
5,405 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:nvms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:DaniPro
ID: 9777470
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";
 }
0
 

Author Comment

by:nvms
ID: 9784490
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
0
 
LVL 6

Accepted Solution

by:
DaniPro earned 150 total points
ID: 9785315
You have right !!!! Then try this code:

public void CopyAllMyText()
 {
    // Determine if any text is selected in the TextBox control.
    if(textBox1.SelectionLength == 0)
       // Select all text in the text box.
       textBox1.SelectAll();
   
    // Copy the contents of the control to the Clipboard.
    textBox1.Copy();
 }
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:nvms
ID: 9785835
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
0
 

Author Comment

by:nvms
ID: 10079190
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.
0
 
LVL 2

Expert Comment

by:krikkit
ID: 10396948
look at this page:

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question