Hi,

When a user clicks a TextBox on a modal form, the caret immediately
moves to the clicked location within the existing text. On a non-modal form,
the user's TextBox click sets the focus appropriately, but fails to set the
caret. How do I correct this behavior? When the user clicks in the midst of
a word within a TextBox, the caret should be placed precisely between the
two characters at the click-point. Any ideas?

Thanks...

Re: TextBox carret not placed correctly by Chien

Chien
Thu Sep 02 16:11:05 CDT 2004

> Hi,
>
> When a user clicks a TextBox on a modal form, the caret immediately
> moves to the clicked location within the existing text. On a non-modal
form,
> the user's TextBox click sets the focus appropriately, but fails to set
the
> caret. How do I correct this behavior? When the user clicks in the midst
of
> a word within a TextBox, the caret should be placed precisely between the
> two characters at the click-point. Any ideas?
>

Not only that, but no text in the TextBox can be selected at ALL via
dragging the mouse. Here's the mind-blowingly weird part.

The problem takes place in a non modal form called CustomerProfileForm.
This non modal form is a child form of the main window. The problem goes
away if the form is created like this:

CustomerProfileForm custForm=new CustomerProfileForm();
custForm.Owner=this;
custForm.Show();

The problem APPEARS if the form is created like this:

CustomerProfileForm custForm=new CustomerProfileForm();
custForm.TopLevel=false;
custForm.Parent=WorkPanel;
custForm.BringToFront();

The obvious solution is: Use the first creation method and avoid the
latter. The problem is: If I use the first creation method, I can't force
the CustomerProfileForm to live within the bounds of the top level window.
I'm stumped.