Solutions Schedule for Silverlight - Gantt style drag and drop multi resource scheduling

How To ...

   
 

Implement Drag and Drop in Microsoft Access   

   
           
  Microsoft Access 2013 introduced new opportunities and among them 64 bit development. A welcomed enhancement from the Financial community who rely heavily on modeling massive amounts of data. Unfortunately for many there was one casualty in the move to 64 Bit development - the Common Controls. The MS Common Controls did not make the trip to 64 Bit.    
           
  DBI's Studio Controls COM 64 has become the perfect replacement for the Common Controls. Through the growing interest in Studio Controls we also receive many requests for how to implement, or is it even possible to implement, Drag and Drop in Microsoft Access?  The lack of a built-in DragDrop event for Controls in MS Access has been the bane of many developers.  There is a solution!    
       
  Here's how to implement Drag and Drop in Microsoft Access (32 Bit and/or 64 Bit):    
           
 
           
   

Code from ctxListView.accdb.zip  available below:

**************************************************

 

Option Compare Database

Dim simulateDrag As Boolean 'indicates if a dragdrop operation is being simulated

 

Private Sub ctxSchedule2_FirstDraw()

'Populate the ctxSchedule control with some items Dim x As Integer

 

For x = 1 To 20

    Me.ctxSchedule2.AddItem "Item " + Str(x)

Next x

 

'Set the highlight color used to paint the currently selected item in the ctxSchedule control.

Me.ctxSchedule2.SelectBackColor = RGB(0, 0, 255) End Sub

 

Private Sub ctxListView1_FirstDraw()

'Populate the ctxListView with some items.

Dim x As Integer

 

For x = 1 To 30

    Me.ctxListView1.AddItem "Job " + Str(x)

Next x

End Sub


 

Private Sub ctxListView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
'A dragdrop simulation will begin

simulateDrag = True

End Sub


 

Private Sub ctxListView1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
'A drag is simulating, so the movement will be tracked

If simulateDrag Then

 

    'Check if the mouse coordinates pass over the instance of ctxSchedule

    If x + Me.ctxListView1.Left >= Me.ctxSchedule2.Left Then

        'Pass the coordinates to a custom routine, to test against the contents of ctxSchedule

        'The coordinates are made relative to the ctxSchedule instance as they are passed to the method

        'In this sample the Top of both the source control (ctxListView) and the target control (ctxSchedule) are the same,

        'so no adjustments need to be made to the y coordinate.

        CheckScheduleLocation (x + Me.ctxListView1.Left) - Me.ctxSchedule2.Left, y, False

    End If

End If

 

End Sub


 

Private Sub ctxListView1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)

'The simulation drag is over

simulateDrag = False

'Check if the mouseup was over the ctxSchedule instance.

    If x + Me.ctxListView1.Left >= Me.ctxSchedule2.Left Then

        'Pass the coordinates to a custom routine, to test against the contents of ctxSchedule

        'The coordinates are made relative to the ctxSchedule instance as they are passed to the method

        'In this sample the Top of both the source control (ctxListView) and the target control (ctxSchedule) are the same,

        'so no adjustments need to be made to the y coordinate.

        CheckScheduleLocation (x + Me.ctxListView1.Left) - Me.ctxSchedule2.Left, y, True

    End If

 

End Sub


 

Private Sub CheckScheduleLocation(ByVal XCoordinate As Single, ByVal YCoordinate As Single, ByVal MouseRelease As Boolean)

 

Dim XCoord As Integer

Dim YCoord As Integer

 

'Convert the coordinates supplied from the Mouse events from Twips to Pixels 'The control requires the coordinates be in Pixels.

XCoord = XCoordinate / 15

YCoord = YCoordinate / 15

 

'Select the item in the ctxSchedule currently under the mouse (will highlight it).

Me.ctxSchedule2.ListIndex = Me.ctxSchedule2.LineAt(YCoord)

 'Test that the mouse was released (indicating a simulated drop) and that the cursor is over the schedule area of the ctSchedule

If MouseRelease And (Me.ctxSchedule2.ScheduleItemAt(XCoord, YCoord) = 3) Then

'Add a new timebar

    Dim newBarIndex As Integer

    newBarIndex = Me.ctxSchedule2.AddTimeBar(Me.ctxSchedule2.LineAt(YCoord), Me.ctxSchedule2.TimeAt(XCoord), Me.ctxSchedule2.TimeAt(XCoord) + 60, Me.ctxSchedule2.DateAt(XCoord), Me.ctxSchedule2.DateAt(XCoord))

    'Set the text of the timebar to the text of the item that triggered the drag

    Me.ctxSchedule2.BarText(Me.ctxSchedule2.LineAt(YCoord), newBarIndex) = Me.ctxListView1.ListText(Me.ctxListView1.ListIndex)

End If

 

End Sub

 

   
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
           
  Download the Drag and Drop MS Access project using ctxListView and ctxSchedule:    
  DBI-Drag-Drop-in-MS-Access (ctxListView.zip)    
           
           
           

 
       
       
DBI Support Products Evaluagte Purchase
         
Customers Technical Support Doc-Tags | xAIgent  Free Trials Order Page
News Releases FAQ Solutions Schedule   Academic
Contact Us Registration Studio Controls Legacy
Updates   Events
Utilities Staff Scheduler Pro
Product Life Cycle Scheduling Framework
   
           
           
  all rights reserved  |  copyright  1996 - 2023 |  Terms of Use