Results 1 to 5 of 5

Thread: Cut And Paste problem

  1. #1

    Thread Starter
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349

    Cut And Paste problem

    I have a problem that involves cutting and pasting into a text box. I have a TextBox_change function that doesn't get called when i use cut and paste. My question is, how do i catch the use of the cut and paste option so that my program can do what it needs to do when the contents of the text box are changed by ANY method?

    Thanx all in advance.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    The Change event should always fire when text is pasted into a textbox.

  3. #3
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    The Textbox_Change event is fired whenever a EN_CHANGE message is fired. Since the message responds to any textbox change (including cut and paste), it will fire on paste.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  4. #4

    Thread Starter
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    Boy is my face red! This should be a warning to me to do a LOT more testing on my code. The problem turned out to have nothing to do with the text box, but with the code i had running to test it. I was highlighting the ENTIRE contents of the text box and pressing delete, and it wasn't updating another form i was using. That was because of the code i called on TextBox_change rather than textbox change not being called.

    Thanx for all the help on this anyway.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  5. #5
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043
    You can use also toolbars Cut,Copy ans Paste buttons this way:
    VB Code:
    1. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    2.    
    3.    Select Case LCase(Button.Key)
    4.     Case "cut"
    5.       If TypeOf Me.ActiveControl Is TextBox Then
    6.          Clipboard.SetText Me.ActiveControl.SelText
    7.          Me.ActiveControl.SelText = ""
    8.       End If
    9.     Case "copy"
    10.       If TypeOf Me.ActiveControl Is TextBox Then
    11.          Clipboard.SetText Me.ActiveControl.SelText
    12.       End If
    13.     Case "paste"
    14.       If TypeOf Me.ActiveControl Is TextBox Then
    15.          Me.ActiveControl.SelText = Clipboard.GetText()
    16.       End If
    17.     End Select
    18.    
    19. End Sub
    oh1mie/Vic


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width