Solved

TextBox Selection : Display value in Label

Posted on 2004-09-14
3
405 Views
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 VS.net in the events list only  "Enter"  is there why?





 
0
Comment
Question by:Jzzzz
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 100 total points
ID: 12058722
I think the code may be in mouseup event and keyup event

private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
  evalSelLen();
}

private void textBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
  evalSelLen();
}

private void   evalSelLen()
{
   Label1.Text=TextBox1.selectedtext.length.tostring();
}
0
 

Author Comment

by:Jzzzz
ID: 12058873
wow.....

exactly!!

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

thanks man.
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12058892
you're welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

16 Experts available now in Live!

Get 1:1 Help Now