Solved

TextBox Selection : Display value in Label

Posted on 2004-09-14
3
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

626 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