![]() |
Drag and drop text in userform text / combo boxes
I am using userforms alot for data entry.
Is there a way to allow one to drag and drop text from one text box / combo box to another? This would be especially useful since it would allow me to move entered data down or up within the userform during editing. However i cannot drag text from one box to another (as one can in say word or in the sheet itself). Can anyone help? |
Drag and drop text in userform text / combo boxes
This is very basic just to get you started. There's a lot more you will
probably want to do, also slightly different approaches - '' put some text in Textbox1 '' press left button and hold Ctrl with mouse over Textbox1 '' drag and release over Textbox2 Private msText As String Private Sub TextBox1_BeforeDragOver( _ ByVal Cancel As MSForms.ReturnBoolean, _ ByVal Data As MSForms.DataObject, _ ByVal X As Single, ByVal Y As Single, _ ByVal DragState As MSForms.fmDragState, _ ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer) Cancel = True End Sub Private Sub TextBox1_MouseDown(ByVal Button As Integer, _ ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Button = 1 And Shift = 2 Then Set dataObj = New MSForms.DataObject msText = TextBox1.Text dataObj.StartDrag End If End Sub Private Sub TextBox1_MouseUp(ByVal Button As Integer, _ ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) msText = "" End Sub Private Sub TextBox2_BeforeDragOver( _ ByVal Cancel As MSForms.ReturnBoolean, _ ByVal Data As MSForms.DataObject, _ ByVal X As Single, ByVal Y As Single, _ ByVal DragState As MSForms.fmDragState, _ ByVal Effect As MSForms.ReturnEffect, _ ByVal Shift As Integer) Cancel = True End Sub Private Sub TextBox2_BeforeDropOrPaste( _ ByVal Cancel As MSForms.ReturnBoolean, _ ByVal Action As MSForms.fmAction, _ ByVal Data As MSForms.DataObject, _ ByVal X As Single, ByVal Y As Single, _ ByVal Effect As MSForms.ReturnEffect, _ ByVal Shift As Integer) TextBox2.Text = msText End Sub Regards, Peter T "Roger on Excel" wrote in message ... I am using userforms alot for data entry. Is there a way to allow one to drag and drop text from one text box / combo box to another? This would be especially useful since it would allow me to move entered data down or up within the userform during editing. However i cannot drag text from one box to another (as one can in say word or in the sheet itself). Can anyone help? |
All times are GMT +1. The time now is 07:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com