place text at cursor location

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reynolds2007
    New Member
    • Apr 2009
    • 3

    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.....plea se help..real urgent project.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    what is the language that you are using ?

    Comment

    • reynolds2007
      New Member
      • Apr 2009
      • 3

      #3
      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.....plea se help..real urgent project.

      I'm using visual basic....

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Originally posted by reynolds2007
        .

        I'm using visual basic....
        Which version of visual basic ?

        Is it VB 6.0 or any version of VB.net ?

        Comment

        • reynolds2007
          New Member
          • Apr 2009
          • 3

          #5
          visual basic express edition 2008
          Last edited by debasisdas; Apr 13 '09, 07:54 AM. Reason: thread moved to vb.net forum.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            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

            Comment

            • aryanbs
              New Member
              • Mar 2009
              • 42

              #7
              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.

              Code:
              Public Class Form1 
                  Private ActiveTextBox As TextBox 
                  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
                      If ActiveTextBox IsNot Nothing Then 
                          ActiveTextBox.AppendText("A") 
                          ActiveTextBox.Select() 
                      End If 
                  End Sub 
               
                  Private Sub StoreActive(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Leave, TextBox2.Leave, TextBox3.Leave, TextBox4.Leave 
                      ActiveTextBox = DirectCast(sender, TextBox) 
                  End Sub 
              End Class

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                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 :)

                Comment

                Working...