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 |
|
|
1 Using System; 2 Using System. Windows. forms; 3 Namespace 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 } Using system; using system. windows. forms; namespace plainclipper {class class1 {[stathread] Static void main (string [] ARGs) {idataobject oldclip = clipboard. getdataobject (); If (oldclip! = NULL) {dataobject newclip = new dataobject (); foreach (string format in oldclip. getformats () {If (format! = "HTML format") {newclip. setdata (format, oldclip. getdata (Format) ;}} clipboard. setdataobject (newclip, true );}}}} |
See orginal article: The smallest useful program I 've ever written