# How can I add items on list view without repeating?

**URL:** <https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946>\
**Category:** Blueprint\
**Tags:** listview, unreal-engine, Blueprint, question\
**Created:** [March 29, 2023, 12:01pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946 "2023-03-29T12:01:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JarmenK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JarmenK](https://forums.unrealengine.com/u/JarmenK)\
**Post date:** [March 29, 2023, 12:01pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/1 "2023-03-29T12:01:37Z")

</div>

I want to add key names into listview without repeating. When I press the button to show the keys I have, I don’t want same keys to repeat. I know it’s about adding list for each loop when every time I pressed the button but I can’t think other option to do it. Here is my blueprint and the issue, how can I fix it?

 ![7845845646](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/a/f7a90cc988df2dc43f485653470a4013df0a9896.jpeg)  
 ![457647](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/6/1562e4a4c300dd1e6f636af2b0116d68ae511c30.jpeg)  
 ![74563467376](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/2/2e255df2fda9cd88f86c3dee486b160ff226ca40.png)

---

<div class="post-metadata">

**Author:** ![dorusoftware](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dorusoftware](https://forums.unrealengine.com/u/dorusoftware)\
**Post date:** [March 29, 2023, 2:11pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/2 "2023-03-29T14:11:58Z")

</div>

you could include various steps, before adding the item check if is already in the list, if it is don’t add it.

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [March 29, 2023, 2:57pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/3 "2023-03-29T14:57:35Z")

</div>

or… if your items are in an array before adding them to the list, use “AddUnique” instead of the normal add.  
And make sure to clear the lists children before repopulating it.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 29, 2023, 3:25pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/4 "2023-03-29T15:25:03Z")

</div>

Use a [Set](https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Sets/) of Enums instead of an array:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/8/0882650b77a1f968cd7641475a25c875f91f5a59.png)

Mainly because I never see anyone use it 😇

---

<div class="post-metadata">

**Author:** ![JarmenK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JarmenK](https://forums.unrealengine.com/u/JarmenK)\
**Post date:** [April 1, 2023, 9:46pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/5 "2023-04-01T21:46:58Z")

</div>

Unfortunately, array items were already added with “addunique”. Sorry for the late response.

---

<div class="post-metadata">

**Author:** ![JarmenK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JarmenK](https://forums.unrealengine.com/u/JarmenK)\
**Post date:** [April 1, 2023, 9:54pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/6 "2023-04-01T21:54:53Z")

</div>

I’m %90 sure that the problem is not with array issues. Array contains key ids in the array data. When I want to add to list widget it’s writing below the last data.  
It’s like  
1: When I have no key when I press the button, nothing appears = that’s normal  
2: When I pickup the first key it says key1 which is normal  
3: But when I pickup the second key it says key1 key1 key2. It’s not updating the list, its writing the array items below it.

Thanks for the advice tho. I’ll consider to use sets.

---

<div class="post-metadata">

**Author:** ![JarmenK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JarmenK](https://forums.unrealengine.com/u/JarmenK)\
**Post date:** [April 1, 2023, 10:18pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/7 "2023-04-01T22:18:49Z")

</div>

![image_2023-04-02_011754474](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/8/b/c8b8e4708a3beb0a955b200ba68a4b25fda3b4a1.png)  
This is the “Add Object To List” Fuction

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [April 3, 2023, 1:44pm UTC](https://forums.unrealengine.com/t/how-can-i-add-items-on-list-view-without-repeating/831946/8 "2023-04-03T13:44:38Z")

</div>

and where is the foreavh loop, that iterates the array?

Made sure that you used

```auto
ListViewWidget -> Clear Children

```

befire iterating iver the array and populating the list again.
