# How to prevent user to add new elements or delete elements from an array?

**URL:** <https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 10, 2014, 4:32am UTC](https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155 "2014-12-10T04:32:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameek4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sameek4](https://forums.unrealengine.com/u/sameek4)\
**Post date:** [December 10, 2014, 4:32am UTC](https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155/1 "2014-12-10T04:32:31Z")

</div>

Hi ,

I am using Editanywhere within UPROPERTY to make my vector array editable , as shown below :

```
UPROPERTY(EditAnywhere, BlueprintOnly, Category = "Road Placeholders", Meta = (MakeEditWidget = true))
	   TArray<FVector> RCTBranchesTop;

```

Now user can definitely modify each vector of the array, but there will be two elements in the array , and user cannot cannot add or delete these two elements from the editor. They will be manipulated only in the code. How do I prevent user from adding elements in this array or removing the existing elements ?

One more issue I saw , when I am changing the value of the vectors from the editor , onpropertychanged property is getting fired but the property name is coming as null :

```
UProperty* PropertyThatChanged = PropertyChangedEvent.Property;
	FName PropertyName = PropertyThatChanged != NULL ? PropertyThatChanged->GetFName() : NAME_None;

```

so I am unable to apply any condition which determined which property ha been changed, and I have to write my propertychange logic in within “else {}”. So for every vector i have declared , the condition present under ELSE is getting fired.

Kindly help.

Thanks and Regards,  
Sameek Kundu

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [December 10, 2014, 9:30am UTC](https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155/2 "2014-12-10T09:30:51Z")

</div>

#Solution

Change your header from

```
UPROPERTY(EditAnywhere, BlueprintOnly, Category = "Road Placeholders", Meta = (MakeEditWidget = true))

```

to

```
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Road Placeholders")

```

Now in BP you can still use the Get node but you will not see Set.

In C++ you can still do whatever you want 🙂

Does this work for you?

#❤

Rama

---

<div class="post-metadata">

**Author:** ![sameek4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sameek4](https://forums.unrealengine.com/u/sameek4)\
**Post date:** [December 10, 2014, 10:30am UTC](https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155/3 "2014-12-10T10:30:22Z")

</div>

Hi Rama,

But in this case the user wont be able to drag the vector variables in the desired direction within the editor. What I want is for theu ser to change the values of the vector variables , but the plus button next to an array , for adding new elements , and the deleting of existing elements should not work.

It is just a road construction automation , an array contains two vectors present at each side of every road branch , and the user can drag those vectors to create new road branch , if the user delete one vector from the array then he will not be able to create branch at that section.

I am not using any Blueprint , it is 100% C++ implementation , i am dragging directly from the class viewer , the user has to make changes in the object property window itself. There only i want this functionality.

---

<div class="post-metadata">

**Author:** ![joeGraf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joeGraf](https://forums.unrealengine.com/u/joeGraf)\
**Post date:** [December 10, 2014, 2:56pm UTC](https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155/4 "2014-12-10T14:56:17Z")

</div>

I don’t believe what you are asking for is possible for dynamic arrays. Properties can be visible (no edit) or editable (defaults only, instance only, anywhere). In the case of the dynamic array, the whole of the array is editable or visible. However, you can use static arrays where you specify the size at compile time.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d055451f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d055451f](https://forums.unrealengine.com/u/anonymous_user_d055451f)\
**Post date:** [October 15, 2018, 7:03am UTC](https://forums.unrealengine.com/t/how-to-prevent-user-to-add-new-elements-or-delete-elements-from-an-array/301155/5 "2018-10-15T07:03:42Z")

</div>

Maybe late, but you can do that with _EditFixedSize_

ex.  
UPROPERTY(EditAnywhere, EditFixedSize, Category = “MyCatNotDog”)  
TArray RCTBranchesTop;
