1

I made drag'n'drop support for TextBox control, but here are some problems with charsets (on special characters).

If I drop that text on my control:

Cześć, chciałbym przetestować specjalne polskie znaki.

It becomes:

Cześć, chciałbym przetestować specjalne polskie znaki.

Here is my code for DragDrop:

private void textBox_DragDrop(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.Text))
    {
        TextBox txt = (TextBox)sender;
        txt.Text = (string)e.Data.GetData(DataFormats.Text);;
    }
    else e.Effect = DragDropEffects.None;
}

When I paste data, everything seems to be ok.

Kacper
  • 268
  • 4
  • 21

2 Answers2

4

Have you tried DataFormats.UnicodeText instead of DataFormats.Text?

Yuriy Guts
  • 2,180
  • 1
  • 14
  • 18
  • What is the source of the drag'n'drop operation (i.e. where are you dragging the data from)? The issue might be that the source uses different encoding than the target. – Yuriy Guts Feb 25 '12 at 13:32
  • Did you change `DataFormats.Text` to `DataFormats.UnicodeText` in **both** places (you have two occurrences of that in your code)? I have reproduced this issue using Chrome but replacing Text with UnicodeText in both lines helped me. – Yuriy Guts Feb 25 '12 at 13:55
1

from this post (http://stackoverflow.com/questions/420659/unicode-characters-not-showing-in-system-windows-forms-textbox)

  1. Try using RichTextBox instead of checkbox and see if it works then - that way you know that you at least read data properly.
user1227804
  • 390
  • 1
  • 5