How to

get (formatted) text from clipboard

Published: 26. September 2014 | Updated: 26. September 2014
License: Microsoft Public License (MS-PL)
Categories: Windows
Tags: C# Text Windows Winforms WPF
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

WPF

using System.Windows;

string text = null;
if (Clipboard.ContainsText(TextDataFormat.Html))
{
    text = Clipboard.GetText(TextDataFormat.Html);
}

WinForms

using System.Windows.Forms;

string text = null;
if (Clipboard.ContainsText(TextDataFormat.Html))
{
    text = Clipboard.GetText(TextDataFormat.Html);
}
Send us feedback about this snippet »



Related Snippets: