Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TextBox Selection : Display value in Label

Posted on 2004-09-14
3
Medium Priority
?
420 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 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