Eto.Forms TextBox.Paste Event?

Is there a TextBox.Paste Event equivalent in Eto.Forms?
I need to handle a multiline or comma-separated string that is pasted and then distributed over multiple textboxes.

@curtisw - is this something you can help with?

Hey @timkado,

No there is no Paste event (and there isn’t one in Windows Forms either). You need to handle the KeyDown event and specifically handle the keystroke, or better yet, use the TextInput event, and do something like the following:

myTextBox.TextInput += (sender, e) => {
  // more than one character is usually from pasting or drag/drop text into the control
  if (e.Text?.Length > 1) {
    var text = e.Text;
    // format text
    myTextBox.SelectedText = text;
    e.Cancel = true; // prevent the text from being pasted
  }
}

Hope this helps!

1 Like