Results 1 to 8 of 8

Thread: [RESOLVED] Drag & Drop MSFlexGrid (Again)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Resolved [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!

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Drag & Drop MSFlexGrid (Again)

    Anyone?

  3. #3
    Hyperactive Member
    Join Date
    May 2005
    Posts
    324

    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.

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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:
    1. Private Sub MSFlexGrid1_DragDrop(Source As Control, x As Single, y As Single)
    2.     If Source Is Me.MSFlexGrid1 Then
    3.         Dim strTemp As String
    4.        
    5.         With Me.MSFlexGrid1
    6.             'make sure all columns are selected
    7.             'required for Clip propertye
    8.             .Col = 0: .ColSel = .Cols - 1
    9.            
    10.             strTemp = .Clip 'save the data in the selected row
    11.            
    12.             .RemoveItem .Row
    13.            
    14.             .AddItem strTemp, .MouseRow + 1 'moves row after
    15.        
    16.         End With
    17.     End If
    18. End Sub
    19.  
    20. Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    21.     If Button = vbRightButton And Me.MSFlexGrid1.MouseCol = 0 Then
    22.         Me.MSFlexGrid1.Drag vbBeginDrag
    23.         Me.MSFlexGrid1.Row = Me.MSFlexGrid1.MouseRow
    24.     End If
    25. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Drag & Drop MSFlexGrid (Again)

    The Code worked great! Props for all.

  6. #6
    Lively Member
    Join Date
    Jan 2006
    Posts
    89

    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?

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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

  8. #8
    Hyperactive Member nepalbinod's Avatar
    Join Date
    Sep 2007
    Posts
    293

    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
  •  



Click Here to Expand Forum to Full Width