Hola. Quisiera saber como hacer drag & drop de un texto, de forma que tenemos un TextBox y queremos pasar su contenido a otro. Lo he intentado con las funciones que incluyen los TextBox, pero no soy capaz.
Gracias de antemano.
Hola,pues se me ocurre asi,puede haber otras formas...
Option Explicit
Private Sub Form_Load()
Text1.OLEDragMode = 1
Text2.OLEDropMode = 1
End Sub
Private Sub Text1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
Text1.OLEDrag
End Sub
Private Sub Text2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Text2.Text = Data.GetData(1)
End Sub
saludos.
Hola, seba123neo. Gracias por la ayuda. Pero no me funciona. Cuando arrastro lo que pone en el TextBox y lo pongo sobre otro, se ve el cursor de arrastrar, pero lo suelo y no hace nada. ¿Tendrá algo que ver que estén bloqueados para impedir su modificación?
Saludos.
Chekeate este si funciona
Private Sub Text1_DragDrop(Source As Control, X As Single, Y As Single)
Text1.Text = Text2.Text
End Sub
Tienes que poner el DragMode del text2 en 1
Talves te funcione
Gracias, pero lo que pasa es que tengo 6 TextBox y quiero que se pueda elegir el que se va a pasar.
Saludos
proba el codigo que te puse yo en un proyecto nuevo y vas a ver que funciona...despues fijate en el tuyo como armarlo...tenes que seleccionar el texto que queres arrastrar para que funcione...
Lo probé en un proyecto nuevo y si funciona, pero en el mío no.
A ver, este es el código que tengo yo:
Private Sub Form_Load()
txtResultado1.OLEDragMode = 1
txtResultado2.OLEDragMode = 1
txtResultado3.OLEDragMode = 1
txtResultado4.OLEDragMode = 1
txtResultado5.OLEDragMode = 1
txtResultado6.OLEDragMode = 1
txtFuerza.OLEDropMode = 1
txtDestreza.OLEDropMode = 1
txtConstitucion.OLEDropMode = 1
txtInteligencia.OLEDropMode = 1
txtSabiduria.OLEDropMode = 1
txtCarisma.OLEDropMode = 1
End Sub
Private Sub txtCarisma_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
txtCarisma.Text = Data.GetData(1)
End Sub
Private Sub txtConstitucion_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
txtConstitucion.Text = Data.GetData(1)
End Sub
Private Sub txtDestreza_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
txtDestreza.Text = Data.GetData(1)
End Sub
Private Sub txtFuerza_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
txtFuerza.Text = Data.GetData(1)
End Sub
Private Sub txtInteligencia_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
txtInteligencia.Text = Data.GetData(1)
End Sub
Private Sub txtSabiduria_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
txtSabiduria.Text = Data.GetData(1)
End Sub
Private Sub txtResultado1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
txtResultado1.OLEDrag
End Sub
Private Sub txtResultado2_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
txtResultado2.OLEDrag
End Sub
Private Sub txtResultado3_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
txtResultado3.OLEDrag
End Sub
Private Sub txtResultado4_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
txtResultado4.OLEDrag
End Sub
Private Sub txtResultado5_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
txtResultado5.OLEDrag
End Sub
Private Sub txtResultado6_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
txtResultado6.OLEDrag
End Sub
Y no me funciona... Si alguien sabe por qué.
Saludos.
EDITADO: esta todo bien ...me fije mal... y una pregunta de que textbox a cual queres pasar por ejemplo...?
Quiero pasar de los txtResultado a los otros. Estoy haciendo una especie de creador de personajes para D&D.
Estuve probando a utilizar Drag en vez de OLEDrag, pero me dice que el espacio de pila es insfuficiente.
Saludos.
pues probe asi como el tuyo pero con 2 textbox y funciona,vos tenes que seleccionar el texto primero y despues ahi podes arrastrarlo..para ahorrarte seleccionarlo podes que cuando tome el foco el textbox se seleccione todo el texto...no tendran alguna propiedad activada qeu le cambiaste y por eso no anda,antes dijiste que estaban bloqueados,pero lo unico que les afecta es el Enabled = False pero con el Locked = True sige funcionando...
saludos.
OK, gracias. No me había dado cuenta. Menuda tontería. Gracias de nuevo.
Saludos.