Link to home
Start Free TrialLog in
Avatar of ybt
ybt

asked on

C# copy data from html table in table format in textbox

In C# I have a WPF textbox in my form, a added a contextmenu:
  <TextBox.ContextMenu>
            <ContextMenu>
                <MenuItem Header="Cut" Click="menu_cut"  />
                <MenuItem Header="Copy" Click="menu_copy"  />
                <MenuItem Header="Paste" Click="menu_paste"  />
            </ContextMenu>
 </TextBox.ContextMenu>
I have html table in browser that look as a picture "file1" in attachment
when I  copy to *.doc I got as a picture "file2"

If I use code:
 private void menu_paste(object sender, RoutedEventArgs e)
        {
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
            {
                 memo_text.Text = memo_text.Text + Clipboard.GetText(TextDataFormat.Text);
               
            }
        }

I got a picture "file3"

If I use code:
 private void menu_paste(object sender, RoutedEventArgs e)
        {
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
            {
                 memo_text.Text = memo_text.Text + Clipboard.GetText(TextDataFormat.Html);
               
            }
        }

I got a picture "file5"

when I use *.doc intermediately and  copy to textbox, result as picture "file4"
How can I get format as "file4" directly?
file1.JPG
file2.JPG
file3.JPG
file4.JPG
file5.JPG
Avatar of Zakaria Acharki
Zakaria Acharki
Flag of Morocco image

I think you've missed referring to the file2.JPG in your question.
Avatar of ybt
ybt

ASKER

You are right, I corrected, fil1 and file2 looks the same
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ybt

ASKER

Thank you very much, this is a new feature for me.