Suerte

[solved] GuiGridListRemoveRow only works on half the rows?

Recommended Posts

I am trying to delete every row in a GridList (named cart):

for i=0,rowCount-1,1 do 
    if guiGridListRemoveRow(cart,i) then 
        outputChatBox("row "..i.." removed") 
    else 
        outputChatBox("err") 
    end 
end 

However, only indexes 0, 2, 4 .. etc. are deleted. Despite this, the debug information in the ChatBox shows there are no errors. i.e. with 4 rows, it will show:

row 0 removed 
row 1 removed 
row 2 removed 
row 3 removed 

But it only works for the even indexes. So when I show the GUI again, index 1, 3, 5 etc.. are still there.

It's probably a noob mistake but yano.

Edited by Guest

Share this post


Link to post
  
for i=0,rowCount do 
 if guiGridListRemoveRow(cart,i) then 
        outputChatBox("row "..i.." removed") 
    else 
        outputChatBox("err") 
    end 
end 
  

the loop is the problem, this might be the solution.

Share this post


Link to post
 for i=0,rowCount do if guiGridListRemoveRow(cart,i) then        outputChatBox("row "..i.." removed")    else        outputChatBox("err")    endend 

the loop is the problem, this might be the solution.

Same result, but thanks.

Ah, I just realised the problem. When row index 0 is deleted, index 1, 2 .. etc. are shifted upwards to 0, 1.. so the next index 1 that is being deleted is actually the original index 2, but the original index 1 never gets touched. I guess it worked that way for all the odd numbers.

Tests confirmed it. Solved code:

for i=0,rowCount do 
    guiGridListRemoveRow(cart,0) 
end 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.