omidaghakhani1368 Well-Known Member Licensed User Longtime User Jul 22, 2015 #1 Hi I add 10 item to customlistview example below Code: Copy 1: for i = 0 to 10 2: dim p1 as panel 3: p1.initialize("") 4: customlistview1.add(p1,100,i) 5: p1.loadlayout("frm1") 6: next when i remove item from 10 items,and again remove item then get error that not exist index i use index from line 4 variable i
Hi I add 10 item to customlistview example below Code: Copy 1: for i = 0 to 10 2: dim p1 as panel 3: p1.initialize("") 4: customlistview1.add(p1,100,i) 5: p1.loadlayout("frm1") 6: next when i remove item from 10 items,and again remove item then get error that not exist index i use index from line 4 variable i
ilan Expert Licensed User Longtime User Jul 22, 2015 #2 if you try to remove like this: cls.RemoveAt(10) then you will get an error and the reason is because in first place you add 11 items and every item you enter a specific value that is the i from the loop now every items index (place in the list) is the same like the value "i", that will stay like this if you wont delete any item but if you delete now index 7 that is in pos 7 your list would look like this item1: value=0 (index or position in list is 0) item2: value=1 (index or position in list is 1) item3: value=2 (index or position in list is 2) item4: value=3 (index or position in list is 3) item5: value=4 (index or position in list is 4) item6: value=5 (index or position in list is 5) item7: value=6 (index or position in list is 6) item8: value=8!!!! (index or position in list is 7) item9: value=9 (index or position in list is 8) item10: value=10 (index or position in list is 9) so if you try to remove item with index 10 you will get an error because your list has now only until index 9 so you will need to search for an item that store that value and remove it... Upvote 0
if you try to remove like this: cls.RemoveAt(10) then you will get an error and the reason is because in first place you add 11 items and every item you enter a specific value that is the i from the loop now every items index (place in the list) is the same like the value "i", that will stay like this if you wont delete any item but if you delete now index 7 that is in pos 7 your list would look like this item1: value=0 (index or position in list is 0) item2: value=1 (index or position in list is 1) item3: value=2 (index or position in list is 2) item4: value=3 (index or position in list is 3) item5: value=4 (index or position in list is 4) item6: value=5 (index or position in list is 5) item7: value=6 (index or position in list is 6) item8: value=8!!!! (index or position in list is 7) item9: value=9 (index or position in list is 8) item10: value=10 (index or position in list is 9) so if you try to remove item with index 10 you will get an error because your list has now only until index 9 so you will need to search for an item that store that value and remove it...
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #3 Sorry, I don't understand clearly. You can remove an Item using RemoveAt(ItemIndex). ItemIndex must be a number between 0 (not 1) and CustomListView1.GetSize - 1. After you removed an item, CustomListView1.GetSize will be decremented by one, of course. Upvote 0
Sorry, I don't understand clearly. You can remove an Item using RemoveAt(ItemIndex). ItemIndex must be a number between 0 (not 1) and CustomListView1.GetSize - 1. After you removed an item, CustomListView1.GetSize will be decremented by one, of course.
ilan Expert Licensed User Longtime User Jul 22, 2015 #4 LucaMs said: Sorry, I don't understand clearly. You can remove an Item using RemoveAt(ItemIndex). ItemIndex must be a number between 0 (not 1) and CustomListView1.GetSize - 1. Click to expand... what i believe is that he is mixing the real index position and the value "i" that he has added in the first loop he need to understand that every time he removes items the index will be different from the value he stored at the first loop because in first loop he has an item with value 10 that is also in index 10 but after delete an item this item will still have value 10 but will be in index 9!! Upvote 0
LucaMs said: Sorry, I don't understand clearly. You can remove an Item using RemoveAt(ItemIndex). ItemIndex must be a number between 0 (not 1) and CustomListView1.GetSize - 1. Click to expand... what i believe is that he is mixing the real index position and the value "i" that he has added in the first loop he need to understand that every time he removes items the index will be different from the value he stored at the first loop because in first loop he has an item with value 10 that is also in index 10 but after delete an item this item will still have value 10 but will be in index 9!!
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #5 Probably, with a few modifications, you can use a Map instead of a List (I'm talking about the internal List of the class) and then give the opportunity to manage the Item by "name" (name can be any object). Upvote 0
Probably, with a few modifications, you can use a Map instead of a List (I'm talking about the internal List of the class) and then give the opportunity to manage the Item by "name" (name can be any object).
ilan Expert Licensed User Longtime User Jul 22, 2015 #6 and what will happen if i have the same name in 2 items?? there MUST be a uniq value for each item like the position (index) Upvote 0
and what will happen if i have the same name in 2 items?? there MUST be a uniq value for each item like the position (index)
ilan Expert Licensed User Longtime User Jul 22, 2015 #8 LucaMs said: you can't Click to expand... Name is something i should choose or have i understood wrong You sugess to search for an item by his name that is something you add to make it easier for you to remember, right? Upvote 0
LucaMs said: you can't Click to expand... Name is something i should choose or have i understood wrong You sugess to search for an item by his name that is something you add to make it easier for you to remember, right?
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #9 ilan said: Name is something i should choose or have i understood wrong You sugess to search for an item by his name that is something you add to make it easier for you to remember, right? Click to expand... Yes, it could be a name but also a number (to avoid the problem of the first post). Simply, you could have a different Add routine (or Add2), like: Add(... Name as Object) and you check if that Name already exists. Upvote 0
ilan said: Name is something i should choose or have i understood wrong You sugess to search for an item by his name that is something you add to make it easier for you to remember, right? Click to expand... Yes, it could be a name but also a number (to avoid the problem of the first post). Simply, you could have a different Add routine (or Add2), like: Add(... Name as Object) and you check if that Name already exists.
ilan Expert Licensed User Longtime User Jul 22, 2015 #10 LucaMs said: Yes, it could be a name but also a number (to avoid the problem of the first post). Simply, you could have a different Add routine (or Add2), like: Add(... Name as Object) and you check if that Name already exists. Click to expand... Ok so you have now something todo... waiting for the new class Upvote 0
LucaMs said: Yes, it could be a name but also a number (to avoid the problem of the first post). Simply, you could have a different Add routine (or Add2), like: Add(... Name as Object) and you check if that Name already exists. Click to expand... Ok so you have now something todo... waiting for the new class
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #11 ... but I don't know CustomListView well (never used) so I'm reading and it has a Value parameter in the routine Add ... I'm reading Upvote 0
... but I don't know CustomListView well (never used) so I'm reading and it has a Value parameter in the routine Add ... I'm reading
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #12 ilan said: Ok so you have now something todo... waiting for the new class Click to expand... Surely, so will I multiply the donations received; they will go from 0 to 0 * 100 Upvote 0
ilan said: Ok so you have now something todo... waiting for the new class Click to expand... Surely, so will I multiply the donations received; they will go from 0 to 0 * 100
ilan Expert Licensed User Longtime User Jul 22, 2015 #14 Maybe you can sell those likes here like people sell likes for facebook Upvote 0
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #15 LucaMs said: ... but I don't know CustomListView well (never used) so I'm reading and it has a Value parameter in the routine Add ... I'm reading Click to expand... If I'm not mistaken, that parameter, Value (which is an Int) is a value associated to an item. So (when I am awake) we could change its type to Object and create a function to get the item by that object. Maybe, because I'm still reading the class. Upvote 0
LucaMs said: ... but I don't know CustomListView well (never used) so I'm reading and it has a Value parameter in the routine Add ... I'm reading Click to expand... If I'm not mistaken, that parameter, Value (which is an Int) is a value associated to an item. So (when I am awake) we could change its type to Object and create a function to get the item by that object. Maybe, because I'm still reading the class.
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #16 ... uhm... but if you add thousands of items... being the search sequential, it would take a long time; using a Map it would be much faster. Upvote 0
... uhm... but if you add thousands of items... being the search sequential, it would take a long time; using a Map it would be much faster.
LucaMs Expert Licensed User Longtime User Jul 22, 2015 #17 LucaMs said: If I'm not mistaken, that parameter, Value (which is an Int) is a value associated to an item. So (when I am awake) we could change its type to Object and create a function to get the item by that object. Maybe, because I'm still reading the class. Click to expand... I'm seeing things; before to me that Value seemed an Int, now an Object! I'm sleepy. Upvote 0
LucaMs said: If I'm not mistaken, that parameter, Value (which is an Int) is a value associated to an item. So (when I am awake) we could change its type to Object and create a function to get the item by that object. Maybe, because I'm still reading the class. Click to expand... I'm seeing things; before to me that Value seemed an Int, now an Object! I'm sleepy.
omidaghakhani1368 Well-Known Member Licensed User Longtime User Jul 22, 2015 #18 Thank you my friends. no no no you wasn't understand. assume i have 10 item in customlistview now i remove item index 4 from list and it removed and again remove index item 4 and it return error i use index from line 4 for position item because i load different layout that contain button and when i click on button should be remove item Upvote 0
Thank you my friends. no no no you wasn't understand. assume i have 10 item in customlistview now i remove item index 4 from list and it removed and again remove index item 4 and it return error i use index from line 4 for position item because i load different layout that contain button and when i click on button should be remove item
ilan Expert Licensed User Longtime User Jul 22, 2015 #19 After removing are you refreshing and loading again all views?? (panels, buttons,...) Upvote 0
omidaghakhani1368 Well-Known Member Licensed User Longtime User Jul 22, 2015 #20 ilan said: After removing are you refreshing and loading again all views?? (panels, buttons,...) Click to expand... I save index of each panel in button tag when i click on button i get button tag (it is index) and then remove item with index but after remove item,count of item in list minus 1 and not exist index how i load all views?your meaning is load all item again? Upvote 0
ilan said: After removing are you refreshing and loading again all views?? (panels, buttons,...) Click to expand... I save index of each panel in button tag when i click on button i get button tag (it is index) and then remove item with index but after remove item,count of item in list minus 1 and not exist index how i load all views?your meaning is load all item again?