---
title: "Problem med richtextbox och urklipp"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/137603-problem-med-richtextbox-och-urklipp"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "saw"
published: "2005-11-14T17:03:28.000Z"
updated: "2005-11-15T13:50:59.000Z"
replies: 2
views: 308
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/137603-problem-med-richtextbox-och-urklipp"
---

# Problem med richtextbox och urklipp

## #1 — saw, 2005-11-14T17:03Z

Rubriken låter fel, men jag kom inte på någonting bättre.
I mitt programm, så ville jag låta klistra in en viss text i en richtextbox via
urklipp.
Så här gör jag idag:

```
string sText="";
	Clipboard.GetDataObject();
	sText = "(" + listView1.SelectedItems[0].SubItems[1].Text + ")";
	Clipboard.SetDataObject(sText);

	IDataObject iData = Clipboard.GetDataObject();
	richTextBoxEx1.SelectionColor = System.Drawing.Color.Blue;
	richTextBoxEx1.Paste();

	info.Text= sText + " " +lasaResurc("strInfAccord");
	richTextBoxEx1.Focus();
```

Detta fungerar bra, men jag ville ändra lite.
I dag blir denna text blå, men jag ville ha så här:
blått = (
rött  = texten som skickas med
blått = )
Är det möjligt att göra detta?  :q

Permalänk: https://www.webforum.nu/p/137603

## #2 — emission, 2005-11-14T21:54Z

```
string sText="";
Clipboard.GetDataObject();
sText = "(" + listView1.SelectedItems[0].SubItems[1].Text + ")";
Clipboard.SetDataObject(sText);

IDataObject iData = Clipboard.GetDataObject();
richTextBoxEx1.SelectionColor = System.Drawing.Color.Blue;
richTextBoxEx1.Paste();
richTextBoxEx1.SelectionStart-=sText.Length-1;
richTextBoxEx1.SelectionLength=sText.Length-2;
richTextBoxEx1.SelectionColor = System.Drawing.Color.Red;
richTextBoxEx1.SelectionStart+=sText.Length-1;
richTextBoxEx1.SelectionLength=0;
info.Text= sText + " " +lasaResurc("strInfAccord");
richTextBoxEx1.Focus();
```

Permalänk: https://www.webforum.nu/p/1707268

## #3 — saw, 2005-11-15T13:50Z

Tack emission , det blev kanonbra.

Permalänk: https://www.webforum.nu/p/1710698

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/137603-problem-med-richtextbox-och-urklipp
