Which TextBox control has focus?

DiverDan

Well-known member
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
User Rank
*Experts*
First, Id like to thank all these people for their time and patience in helping us newbies.

I have a form with many textboxes. Id like to know which form has focus so that Cut, Copy, Paste can work on it. And I cant understand how to find which textbox has focus.
 
Use
Code:
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 Im having a bit of a problem with the copy and cut commands...Please Help!
 
I think Textboxes have proper clipboard commands:

Code:
DirectCast(Me.ActiveControl, TextBox).Cut()
 
divil...it works great! I thought only RTF boxes were capabile of proper clipboard commands...guess not.

Thanks for your help!
 
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 doesnt get any simplier...Thanks again divil!!!
 
Back
Top