Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any boolean function that returns whether a TextBox has the input cursor in it or not?

it should look like this:

C#
if(textBox1.HasCursor)
{
    //do something
}
Posted
Updated 28-Sep-11 4:36am
v2
Comments
BobJanova 28-Sep-11 13:34pm    
Is it WinForms? WPF? Silverlight? HTML? I gave a WinForms answer and Dasblinkenlight gave you a WPF/Silverlight one and you have just claimed they don't work. Your question is unclear.

Use Keyboard.FocusedElement[^] to see which element has the focus (and of course the cursor that goes with it).
 
Share this answer
 
Comments
George_Rasmi 28-Sep-11 10:41am    
can you give me more details? a small code???
dasblinkenlight 28-Sep-11 10:57am    
if (textBox1.Equals(Keyboard.FocusedElement)) // Do something
George_Rasmi 28-Sep-11 11:23am    
It's not working :(
I included System.Windows.Input to the project but I still don't have a Keyboard class
Control.Focused[^]. (If a text box has the focus, then by definition it also has the input cursor.)
 
Share this answer
 
Comments
George_Rasmi 28-Sep-11 10:37am    
it tried this code but it didn't work :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900