469,331 Members | 1,912 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

place text at cursor location

I have 9 Text boxex and one command button and I'm looking for a code such that IF i set my cursor on a specific textbox using the mouse then I can be able to Input text in the textbox using the command button.....please help..real urgent project.
Apr 8 '09 #1
7 2446
debasisdas
8,127 Expert 4TB
what is the language that you are using ?
Apr 8 '09 #2
I have 9 Text boxex and one command button and I'm looking for a code such that IF i set my cursor on a specific textbox using the mouse then I can be able to Input text in the textbox using the command button.....please help..real urgent project.

I'm using visual basic....
Apr 8 '09 #3
debasisdas
8,127 Expert 4TB
@reynolds2007
Which version of visual basic ?

Is it VB 6.0 or any version of VB.net ?
Apr 9 '09 #4
visual basic express edition 2008
Apr 11 '09 #5
Frinavale
9,735 Expert Mod 8TB
This can be accomplished using the TextBox's Focused Event and the AddHandler Statement.


For every TextBox that you want to do something when it has focused you will use the AddHandler statement to indicate which method should be called during the Focused event.

-Frinny
Apr 14 '09 #6
aryanbs
42
Following code is storing textbox in a variable when you leave the textbox (that is when you click the button), look at storesctive proc which is handling 4 textboxes leavve event.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1 
  2.     Private ActiveTextBox As TextBox 
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
  4.         If ActiveTextBox IsNot Nothing Then 
  5.             ActiveTextBox.AppendText("A") 
  6.             ActiveTextBox.Select() 
  7.         End If 
  8.     End Sub 
  9.  
  10.     Private Sub StoreActive(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Leave, TextBox2.Leave, TextBox3.Leave, TextBox4.Leave 
  11.         ActiveTextBox = DirectCast(sender, TextBox) 
  12.     End Sub 
  13. End Class 
Apr 14 '09 #7
Frinavale
9,735 Expert Mod 8TB
Oh yeah I forgot about the Handles keyword for methods.

I've been doing everything dynamically for so long now and so I tend to forget the quick/simple way of doing things.

Thanks for that Aryandbs :)
Apr 14 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by oketz1 | last post: by
1 post views Thread by Roshan | last post: by
4 posts views Thread by Strahimir Antoljak | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.