TextBox Selection : Display value in Label

Posted on 2004-09-14
Last Modified: 2012-05-05
I want to dispaly the selected text in a "textbox" in a label
when my app is running.
I have other control also on my form. datagrids  for updating information and other button controls.

So, when the user selects text in the textbox which is bound to a datasource , i need to display the  number of characters in the selected text like this
         label.text = textbox.selectedtext.length.tostring();

My question is which event of the textbox do i use.

Enter / Focus/ Leave/ LostFocus etc.

In in the events list only  "Enter"  is there why?

Question by:Jzzzz
  • 2

Accepted Solution

tzxie2000 earned 100 total points
Comment Utility
I think the code may be in mouseup event and keyup event

private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)

private void textBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

private void   evalSelLen()

Author Comment

Comment Utility


I wouldn't have figured that in a hundred years..:)

thanks man.

Expert Comment

Comment Utility
you're welcome

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now