Drag select cells in grid

Just starting out? Need help? Post your questions and find answers here.
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

Drag select cells in grid

Post by wombats »

Hi,

I am trying to create a grid with the CanvasGadget. I can drag select cells as long as the last selected cell is greater than the first selected cell:

Code: Select all

If mX => colX(c) And mX <= colX(c) + *array\colWidths(c)
  If mY => rowY(r) And mY <= rowY(r) + *array\rowHeights(r)
    *array\selEndR = r
    *array\selEndC = c
    If *array\selEndC < *array\selStartC
      
    EndIf
    If *array\selEndR < *array\selStartR
      
    EndIf
    DrawGrid()
    Break
  EndIf
EndIf
How can I adapt this code to work when the user is dragging in the other directions?

I'm not using one of the existing grid controls available on the forums as I want to build my own from scratch to meet my needs.