Fengzhimei@Dot.Net
Designing My Colorful Dream
    When you copy from one program's document and paste in another program's document, you almost never want to keep the formatting.A simple example is when you copy from word or other document into the rich text control that .Text uses on the New Post page, you get a hunk of unwanted HTML around the pasted text.What a worry it is!
    Ok, Maybe this program can help you out:)

Rich Code Plain Code  
1using System;
2using System.Windows.Forms;
3namespace PlainClipper {
4  class Class1 {
5    [STAThread]
6    static void Main(string[] args) {
7      IDataObject oldclip = Clipboard.GetDataObject();
8      if (oldclip != null) {
9        DataObject newclip = new DataObject();
10        foreach (string format in oldclip.GetFormats()) {
11          if (format != "HTML Format") {
12            newclip.SetData(format, oldclip.GetData(format));
13          }
14        }
15        Clipboard.SetDataObject(newclip, true);
16      }
17    }
18  }
19}

See Orginal Article: The smallest useful program I've ever written
posted on 2004-05-25 16:24  fengzhimei  阅读(1159)  评论(2编辑  收藏  举报