Which TextBox control has focus?

DiverDan

Contributor
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
First, I'd like to thank all these people for their time and patience in helping us newbies.

I have a form with many textboxes. I'd like to know which form has focus so that Cut, Copy, Paste can work on it. And I can't understand how to find which textbox has focus.
 
Use
Visual Basic:
Me.ActiveControl
to return the currently active control
on a form.
 
Ok...I got the paste command;
If Clipboard.GetDataObject.GetDataPresent(DataFormats.Text) Then
Me.ActiveControl.Text = Me.ActiveControl.Text & Clipboard.GetDataObject.GetData(DataFormats.Text)
End If

But I'm having a bit of a problem with the copy and cut commands...Please Help!
 
I think Textboxes have proper clipboard commands:

Visual Basic:
DirectCast(Me.ActiveControl, TextBox).Cut()
 
Cut:
DirectCast(Me.ActiveControl, TextBox).Cut()

Copy:
DirectCast(Me.ActiveControl, TextBox).Copy()

Paste:
If Clipboard.GetDataObject.GetDataPresent(DataFormats.Text) Then
DirectCast(Me.ActiveControl, TextBox).Paste()

It doesn't get any simplier...Thanks again divil!!!
 
Back
Top