Skip to main content

BaseListBoxControl.SetItemValue(Object, Int32) Method

Assigns a new value to the specified item.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public void SetItemValue(
    object itemValue,
    int index
)

Parameters

Name Type Description
itemValue Object

An object representing a new value to be assigned to the specified item.

index Int32

An integer value representing the zero-based index of the item to which a new value is assigned.

Remarks

Use the SetItemValue method to assign a new value to the item specified by the parameter. There are two cases you should note. First, when no data source is assigned to a control, the item’s display text is nothing else but a string representation of the object representing its value. Thus, assigning to the item a new value will automatically change its display text. Second, when a data source is bound to the control; In this case, the DisplayText, represents the contents of the field specified by the BaseListBoxControl.DisplayMember property. The item value, in turn, represents the contents of the field specified by the BaseListBoxControl.ValueMember property. If the DisplayMember and ValueMember properties are set to the same field name, assigning item a new value will automatically change it’s display text. Otherwise, only the item’s value will be changed.

Note: calling the SetItemValue method will have no effect if no item is found.

If the currently selected item’s value has been changed, the BaseListBoxControl.SelectedValueChanged event fires.

See Also