Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    May 2006
    Posts
    16

    Grid Selection Question

    I have not found a solution yet on the forums, but am still looking.
    I am trying to reproduce a listbox as a Grid (a lot more features i can use with the grid such as multiple colors/fonts on the same line). With a listbox, I can have multiple selection enabled and get the selected rows with ListBox.GetSelected()
    If there are multiple rows, it returns multiple indexes in a table.
    I can also set the Selected Inexes using ListBox.SetSelected()
    Can the same be done with a Grid? The end result, I need to be able to Get which Rows are selected (currently using ListMode), and being able to select Multiple Rows. These rows may not be one after another either.

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Not "directly" as I see it there is no Grid.GetSelectedCells() call; but there are two functions of use:

    To determine if any cells are selected:
    Code:
    Grid.GetSelectedCount()
    Then you could loop thru the grid looking for cells that are selected via:
    Code:
    Grid.IsCellSelected()


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    May 2006
    Posts
    16
    Quote Originally Posted by jassing View Post
    Not "directly" as I see it there is no Grid.GetSelectedCells() call; but there are two functions of use:

    To determine if any cells are selected:
    Code:
    Grid.GetSelectedCount()
    Then you could loop thru the grid looking for cells that are selected via:
    Code:
    Grid.IsCellSelected()
    mmk thanks jassing, that worked for getting the selected. Pretty fast on a grid of 100-150 objects. The code i used specifically was:

    Code:
    function FindSelectedGrid(strGrid)
    	if (Grid.GetSelectedCount(strGrid)>0) then
    		local x=0;
    		while (x<(Grid.GetRowCount(strGrid)-1)) do -- minus 1 for the header - Remove if no header
    			x=x+1;
    			if (Grid.IsCellSelected(strGrid, x, 0)) then
    				--Do Your action here
    				Debug.Print("Row:"..x.." is selected. Value of Column 1 is:"..Grid.GetCellText(strGrid, x, 1).."\r\n");
    			end
    		end
    	end
    end
    FindSelectedGrid("Grid1");

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    I tested with a fairly large grid of random data and randomly selected cells -- I expected it to be slower; but seems the grid access is fast...
    Glad you got it going.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  5. #5
    Join Date
    May 2006
    Posts
    16
    Still looking for a way to do multiple selects via Action Calls.
    SetSelectedRange works, if they are all one after another. It doesn't seem to work in there are rows in between that are not to be selected though.

  6. #6
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    You can select one or more rows using Grid.SetSelectedRange()
    Dermot

    I am so out of here

  7. #7
    Join Date
    May 2006
    Posts
    16
    Quote Originally Posted by Dermot View Post
    You can select one or more rows using Grid.SetSelectedRange()
    What if I want to select Rows 1,2 and 4, but not Row 3?

  8. #8
    Join Date
    May 2006
    Posts
    16
    Found a way to do it
    I just rewrote all of the ListBox functions as Grid Functions.

    A sample project demonstrating them all is here:
    New functions are:
    Grid.ClickWorkAround(strGrid)
    Grid.AddItem(strGrid,strText,strData)
    Grid.AddItemTable(strGrid,tblData)
    Grid.FindItem(strGrid,nStart,strType,strData)
    Grid.FindItemAnywhere(strGrid,nStart,intCol,strDat a)
    Grid.SetItemData(strGrid,nIndex,strData)
    Grid.InsertItem(strGrid,nIndex,strText,strData)
    Grid.InsertItemTable(strGrid,nIndex,tblData)
    Grid.IsItemSelected(strGrid,nIndex)
    Grid.SetItemText(strGrid,nIndex,strText)
    Grid.SetItemTable(strGrid,nIndex,tblData)
    Grid.GetItemData(strGrid,nIndex)
    Grid.GetItemText(strGrid,nIndex)
    Grid.GetItemTable(strGrid,nIndex)
    Grid.SelectItem(strGrid,nRow)
    Grid.DeselectItem(strGrid,nRow)
    Grid.GetSelected(strGrid)
    Grid.GetSelectedCountCustom(strGrid)

    example follows
    Attached Files

  9. #9
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Interesting Idea -- I got a # of errors ("not a table" etc from lack of information on how to use it...) and finally got the attached...

    Repeated it twice.

    Might be a bug for IR


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  10. #10
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    I get lots of errors also and the Grid.SelectItem does not seem to work. The c stack error is because you are causing an infinite loop which repeatedly calls the ClickWorkAround() function. You don't need any new function to handle single clicks because the row is selected when you click on it. Worm posted an excellent solution to handle double clicks.
    Dermot

    I am so out of here

  11. #11
    Join Date
    May 2006
    Posts
    16
    Quote Originally Posted by Dermot View Post
    I get lots of errors also and the Grid.SelectItem does not seem to work. The c stack error is because you are causing an infinite loop which repeatedly calls the ClickWorkAround() function. You don't need any new function to handle single clicks because the row is selected when you click on it. Worm posted an excellent solution to handle double clicks.
    Hmm Can't pull up the attached picture (must login and refresh page, but have already logged in and refreshed...) but I am not getting the errors on my end.

    I'm not on the 7.5 yet, still on 7.1, perhaps that is why. As far as the Selection goes, I have used part of Worm's example for the double click in the "ClickWorkAround". My specific needs require that multiple non continuous rows, therefore the normal Select won't work. I wrote the Grid.SelectItem as an alternative for the Grid.SelectRange. The workaround isn't for catching single clicks in so much as catching doubleclicks without using a hot spot, and for "selecting" the entire row with a single click while preserving previous selected Rows, and having the ability to select individual rows via actions.

    Thank-you for the input though, I will try to reproduce the errors and correct them

  12. #12
    Join Date
    May 2006
    Posts
    16
    Quote Originally Posted by thisisauniqueusername View Post
    Hmm Can't pull up the attached picture (must login and refresh page, but have already logged in and refreshed...) but I am not getting the errors on my end.

    I'm not on the 7.5 yet, still on 7.1, perhaps that is why.
    Fix: Fixed a bug where the "Grid.SetSelectedRange" action was not firing the grid's "On Selection Changed" event.
    And that's probably why I did not get the error... Well scratch that part of it then

  13. #13
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Have you tried with the Grid set to ListMode?

    http://www.indigorose.com/webhelp/am...etListMode.htm

  14. #14
    Join Date
    May 2006
    Posts
    16
    the endless loop needs the "Grid.SetSelectedRange" part commented out i believe to quit the endless loop.

    Even on Listmode, when inside a function, using the builtin Grid Functions IR provided, I could not see a way to select specifically Lines 1,2,4 and not 3.

    The range only appears to select from one start cell to one end cell, and everything in between. Calling multiple SetSelectedRange would end up with only the last one called being selected.

    example:
    given grid with 4 rows, 4 columns
    function myfunct()
    Grid.SetSelectedRange("Grid1", 0, 0, 0, 3, true, true); - First row selected only
    Grid.SetSelectedRange("Grid1", 1, 0, 1, 3, true, true); - First row deselected, 2nd row selected
    Grid.SetSelectedRange("Grid1", 3, 0, 3, 3, true, true); - 2nd row deselected, 4th row selected
    end

Similar Threads

  1. Suggestions: Grid
    By bule in forum AutoPlay Media Studio 7.5 Suggestions
    Replies: 6
    Last Post: 08-05-2008, 08:40 PM
  2. Grid Question
    By ShadowUK in forum AutoPlay Media Studio 7.5
    Replies: 1
    Last Post: 07-23-2008, 04:40 PM
  3. Grid Problems
    By Solmos in forum AutoPlay Media Studio 7.5
    Replies: 2
    Last Post: 03-17-2008, 09:31 AM
  4. simple grid question
    By qwer in forum AutoPlay Media Studio 6.0
    Replies: 2
    Last Post: 08-22-2007, 03:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts