Article ID: 113436
Article Last Modified on 1/9/2003
' Dragging is a flag used for each control to determine ' if something is being dragged. Dim dragging As Integer Dim text_to_drag$
Sub Form_Load ()
' Initialize the grid control:
Grid1.Cols = 3
Grid1.Rows = 60
Dim db As database
Dim ds As dynaset
Dim counter%
grid1.ColWidth(1) = 3000 'For Author name
grid1.ColWidth(2) = 1000 'For Author ID
grid1.Col = 1
grid1.Row = 0
grid1.Text = "Author Name" 'Header for Author Name
grid1.Col = 2
grid1.Row = 0
grid1.Text = "Author ID" 'Header for Author ID
Set db = OpenDatabase("BIBLIO.MDB")
Set ds = db.CreateDynaset("Authors")
counter% = 1 'Start counter at Row=1
Do Until ds.EOF Or counter% = 60
grid1.Col = 1
grid1.Row = counter%
grid1.Text = "" & ds(1) 'Load the Author Name
grid1.Col = 2
grid1.Row = counter%
grid1.Text = "" & ds(0) 'Load the Author ID
counter% = counter% + 1
ds.MoveNext
Loop
ds.Close
db.Close
End Sub
Sub Grid1_Click ()
' Highlight entire row:
Dim highlight%
highlight% = grid1.Row
grid1.SelStartRow = highlight%
grid1.SelEndRow = highlight%
grid1.SelStartCol = 1
grid1.SelEndCol = 2
End Sub
Sub Grid1_DragDrop (Source As Control, X As Single, Y As Single)
grid1.Drag 0
dragging = False
End Sub
' Enter the following two lines as one, single line:
Sub Grid1_MouseDown (Button As Integer, Shift As Integer,
X As Single, Y As Single)
' If the mouse goes down, set the dragging flag in case this
' is for a drag:
Dim selected%
dragging = True
selected% = grid1.Row
grid1.Col = 1
text_to_drag$ = Trim$(grid1.Text)
End Sub
' Enter the following two lines as one, single line:
Sub Grid1_MouseMove (Button As Integer, Shift As Integer, X As
Single, Y As Single)
' If the dragging flag was set, then we will enable the drag
' MouseDown has to set the flag first
If dragging Then
dragging = False ' Cancel the flag.
grid1.Drag 1 ' Start the drag mode.
Else
grid1.Drag 0 ' Cancel if flag was not set.
End If
End Sub
' Enter the following two lines as one, single line:
Sub Grid1_MouseUp (Button As Integer, Shift As Integer, X As
Single, Y As Single)
' Mouse released on text box, so cancel the dragging mode:
grid1.Drag 0
dragging = False
End Sub
Sub List1_DragDrop (Source As Control, X As Single, Y As Single)
List1.AddItem text_to_drag$ ' This inserts the text.
End SubAdditional query words: 1.00 2.00 3.00
Keywords: KB113436