Page 1 of 1

Data Grid Multiple Select Query

Posted: Sat Sep 10, 2011 2:59 pm
by Phil_p
Hi

I would like to know how I can use a variable instead of the ctrl key to select multiple rows. At the moment you need to ctrl click on the rows but I would like to have a variable which is set to true or false, when true it will be as if you have ctrl clicked on a row.

Hope this makes sense

regards

Phil

Re: Data Grid Multiple Select Query

Posted: Sat Sep 10, 2011 4:16 pm
by sturgis
If you are using a datagrid form, something like the following should work in the row behavior script.

Code: Select all

on mouseDown
   if the mycheckprop of this stack is true then -- check flag property
      set the wholematches to true -- to avoid accidental matches
      put the dgHilitedLines of me into tLines -- grab currently hilited
      put itemoffset(the dgLine of me,tLines) into tMatch -- see if line is already hilited
      if tMatch > 0 then -- if line is already hilited, remove it from the list
         delete item tMatch in tLines
         set the dgHilitedLInes of me to tLines -- set updated hilite list
      else -- if line isn't already hilited
         put the number of items in tLines + 1 into tNum
         put the dgLine of me into item tNum of tLines -- add it to the list of items in tLines
         sort items of tLines ascending numeric -- sort em. Don't know if this matters or not
         set the dghilitedlines of me to tLines -- set to the updated hilite list
      end if
   else -- if our property is false, just pass mouseDown
      pass mouseDown
   end if
end mouseDown
To toggle it with code:

Code: Select all

set the mycheckprop of this stack to true -- turns it on
set the mycheckprop of this stack to false -- turns it off
It would be a bit more complex (maybe?) when dealing with a table rather than a form, but the idea should be similar.

Re: Data Grid Multiple Select Query

Posted: Sat Sep 10, 2011 6:30 pm
by Phil_p
I was along the right lines with this but that looks like it will work a treat.

Many thanks