TextBox insertion point

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi. i have a control derived from TextBox. how can i set this up such that
all text is always selected (i.e. the insertion point is never shown). i was
hoping for an OnEnteringEdit method or similar but no such luck. do i just
need to capture mouse clicks or are there multiple methods of entering edit
mode on a TextBox?

thanks

kh
 
Hi,

Thank you for posting. From your post, my understanding on this issue is:
you have a control derived from TextBox and you want your control to select
all text in it when it is clicked. If I'm off base, please feel free to
let me know.

To make your control select all text in it when you click it, you should
handle the control's click event(since your control is derived from TextBox
and TextBox has click event, your control has click event as well). In the
event handler for the control's click event , you may use the sentence to
select all text in it: this.SelectAll();

The following is a sample.

class TextBoxExt:TextBox
{
public TextBoxExt()
{
this.Click += new EventHandler(TextBoxExt_Click);
}

void TextBoxExt_Click(object sender, EventArgs e)
{
this.SelectAll();
}
}

Hope this is helpful to you.

If you have any other concerns or need anything else, please don't hesitate
to tell me.

Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Back
Top