PDA

View Full Version : Grid operation failed


Teqskater
10-23-2008, 11:54 AM
Hello,
Im having an error when trying to set a cell's text in a grid: Grid operation failed.
Does someone have a solution or workaround for this. Or maybe an advice to search for the bug. Im sure the grid is editable. If not the case the program makes the grid editable.

I think im tired and therefor don't see the error i've possibly made myself:
totaal = 0
for x = 1, nRows-1 do
add = Grid.GetCellText("Grid1", x, e_Column);
add = String.ToNumber(add)
totaal = totaal + add
end
IsEditable = Grid.IsCellEditable("Grid1", nRows, e_Column);
if IsEditable == true then
Grid.SetCellText("Grid1", nRows, e_Column, ""..totaal.."", true);
elseif IsEditable == false then
Grid.SetEditable("Grid1", true);
Grid.SetCellText("Grid1", nRows-1, e_Column, ""..totaal.."", true);
Grid.SetEditable("Grid1", false);
end
Totaal = dutch for total. So what this code part does is count all rows in a specific row together and store the output into the last cell in a row. the variable nRows id defined like this:
nRows = Grid.GetRowCount("Grid1");

jassing
10-23-2008, 06:19 PM
What line gives you what error?

Dermot
10-23-2008, 06:24 PM
Where are you calling this code from? e_Column is only available in the grid On Cell Changed and On Selection Changed events.

The grid does not have to be editable in order to set the value of a cell from code. That only applies to allowing the user to type values into the cells.

Teqskater
10-24-2008, 03:09 PM
totaal = 0
for x = 1, nRows-1 do
add = Grid.GetCellText("Grid1", x, e_Column);
add = String.ToNumber(add)
totaal = totaal + add
end
IsEditable = Grid.IsCellEditable("Grid1", nRows, e_Column);
if IsEditable == true then
Grid.SetCellText("Grid1", nRows, e_Column, ""..totaal.."", true);
elseif IsEditable == false then
Grid.SetEditable("Grid1", true);
Grid.SetCellText("Grid1", nRows, e_Column, ""..totaal.."", true);
Grid.SetEditable("Grid1", false);
end

Dialog.Message("Notice", "totaal:"..totaal.."\nKolom:"..e_Column.."\nRij:"..nRows.."", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

There is no error on runtime actualy. When i look for an error when i use the application.getlasterorr or whatever the code was after the code above, and show it via a dialog it returned that error. the code above needs to count all values of a column together exept the last one and set the last row in that column to the value stored in the variable totaal. and on runtime it didnt do anything. So then i used the last line in the above code to display al values involved. and that was ok. Then i retrieved that error via application.getlasterorr or what it was and gave me that error.

i called the code from the On Cell Changed event