has a tip as to why this doesn't work.
I'm wanting to add and delete rows in a datagrid form by clicking on a button object in an existing row.
A row is to be added or deleted just below the row where the button object is clicked. The action add/dele is based on the state of the icon of the button.
What I have works great, to a point.
The whole thing breaks after n+1 add/remove cycles, where n=the number of rows the form is populated with.
For example, if the grid is populated with three rows, I can add and remove rows below any of the original rows in
any order or combination but on the forth (n+1) add, the row is added, but then it can not be deleted nor can other rows be added.
I've populated the data grid with various numbers of rows and on the n+1 add, it stops working - something with the data grid breaks.
Any ideas are appreciated....
Code: Select all
on mouseup mouseButtonNumber
if mouseButtonNumber = 1 and the target contains "Expandbtn" then
put the dgHilitedLines of the group "DataGrid 1" into gMyID
put the dgIndex of me into gMyIndex
put the long ID of the target into gMyLongID
if the icon of the target = "200951" then // delete row
set the icon of the target to "200946"
put gMyID+1 into RowToDelete
dispatch "deleteline" to group "DataGrid 1" with RowToDelete
put the result into theNewIndex
else //insert row
put "Bobo Bolinsky and the Social Context" into theData["Title"]
put "Jim" into theData["Name"]
put "1.1.3.1" into theData["Level"]
put gMyID+1 into theData["Index"]
set the icon of the target to "200951"
dispatch "AddData" to group "DataGrid 1" with theData, theData["Index"]
put the result into theNewIndex
end if
end if
end mouseup