-1

I have a windows form that uses DevExpress (although I'm not sure if that's part of the issue or not) which is being used to generate an email in csharp. When content has been entered into the control (e.g. selected an email address from a lookup, typed content into the message field) I can no longer set the cursor by clicking into the field.

Double-clicking does select sections of text, and from there the cursor can be displayed and moved with the arrow keys - but not by clicking again.

There are a number of different controls on the form, including a DevExpress LookupEdit and a memo field - but for the issue encountered, the control type doesn't seem to matter - adding different controls has the same issue.

I can't find any settings or configuration that I think could cause this issue - has anyone else encountered anything like this and can shed some light on fixing the problem?

Thanks!

Jon

Jon
  • 1
  • 2
  • If I remember correctly, the TextEdit at least has a property like 'AutoSelect' or something that defaults to true. – DrewJordan May 27 '15 at 17:34
  • If it were one control, it would explain it - but it's all, including new controls - both DevExpress and non-DevExpress! It appears to be something not specific to controls. I can't find any sort of property even remotely like 'AutoSelect' either! – Jon May 28 '15 at 08:27
  • "Double-clicking does select sections of text, and from there the cursor can be displayed and moved with the arrow keys"... this sounds like the behavior of a control that's been made readonly... are you *sure* that's not the case? Maybe it's being set in an event somewhere? – DrewJordan May 28 '15 at 12:13
  • Absolutely certain, I've been through the code line-by-line and they're not read-only. They can be edited once they have focus by using the arrow keys and typing. – Jon May 28 '15 at 13:34

1 Answers1

0

Found the answer - it was the same problem as encountered here:

Windows Forms: Unable to Click to Focus a MaskedTextBox in a Non TopLevel Form

The form was being opened as toplevel=false with a parent, but as a dialog so wasn't being activated - which is why it could be accessed but not process certain windows events such as a mouse click.

Weird, but removing the caption bar (formborderstyle = none) fixed the problem!

The final solution appears to relate to how the parent is set on the child form. In my instance, we needed the form to be confined within the bounds of the parent and be able to be moved around, so borderless didn't really solve the issue. What did was this:-

// Declaration
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

// Displaying child form
SetParent(modalForm.Handle, this.Handle);
modalForm.Show();
Community
  • 1
  • 1
Jon
  • 1
  • 2