-
Jul 30th, 2005, 06:27 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Drag & Drop MSFlexGrid (Again)
Alright, this time I'm wondering why do I see people drag drop to several flex grids and not one.
I just wish to move a row when the first column (0) is clicked and held. Then you can move it up/down and all around (vertical) within it's MSFlexGrid Atmosphere.
I know I would need to use a mousedown thinger but is there any code I can be pointed too if ya'll have dealt with this before.
Much thanks!
-
Jul 30th, 2005, 09:28 PM
#2
Thread Starter
Addicted Member
Re: Drag & Drop MSFlexGrid (Again)
-
Jul 31st, 2005, 02:19 AM
#3
Hyperactive Member
Re: Drag & Drop MSFlexGrid (Again)
Moving the row vertically would be fairly straightforward, but I don't see how you can move a row horizontally.
To drag the row vertically you'd need to invoke a drag event on .mousedown (if .mousecol=0) then respond to the .dragdrop event. I would suggest adding a row first at the new location (using .additem), populating it with data from the old row cell by cell, then removing the old row using .removeitem.
-
Jul 31st, 2005, 11:30 AM
#4
Re: Drag & Drop MSFlexGrid (Again)
Moving rows within a FlexGrid is pretty straight forward. Using Drag and Drop is not required but since that is what you asked about. Make sure you set the DragIcon property of the grid to a valid icon or cursor.
VB Code:
Private Sub MSFlexGrid1_DragDrop(Source As Control, x As Single, y As Single)
If Source Is Me.MSFlexGrid1 Then
Dim strTemp As String
With Me.MSFlexGrid1
'make sure all columns are selected
'required for Clip propertye
.Col = 0: .ColSel = .Cols - 1
strTemp = .Clip 'save the data in the selected row
.RemoveItem .Row
.AddItem strTemp, .MouseRow + 1 'moves row after
End With
End If
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton And Me.MSFlexGrid1.MouseCol = 0 Then
Me.MSFlexGrid1.Drag vbBeginDrag
Me.MSFlexGrid1.Row = Me.MSFlexGrid1.MouseRow
End If
End Sub
-
Jul 31st, 2005, 08:23 PM
#5
Thread Starter
Addicted Member
Re: Drag & Drop MSFlexGrid (Again)
The Code worked great! Props for all.
-
Jun 11th, 2007, 11:38 PM
#6
Lively Member
Re: [RESOLVED] Drag & Drop MSFlexGrid (Again)
what if we have to update the row position in the table in access database after drag and drop in msflexgrid?
-
Jun 12th, 2007, 01:01 PM
#7
Re: [RESOLVED] Drag & Drop MSFlexGrid (Again)
There's no guaranteed default position in a database. The recordset you get from the database is dependent on the Order By clause if there is one, or the database code itself if there isn't one.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jan 30th, 2009, 01:22 PM
#8
Hyperactive Member
Re: [RESOLVED] Drag & Drop MSFlexGrid (Again)
This code is amazing!!!
Futher, while dragging and dropping, is it possible to highlight the source row and current row (where the mouse is) for better visibility.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|