Solved

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

Posted on 2003-11-19
6
5,392 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 50 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 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