DgsComboBoxSetItemData

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function sets an Item Data associated to a combo box item.

Syntax

bool dgsComboBoxSetItemData ( element combobox, int itemIndex, mixed data )

Required Arguments

  • combobox: the combobox containing the item you're interested in.
  • itemIndex: the item index of the item.
  • data: the data you want to set.

Returns

Returns true if set successfully, false if one of the arguments was invalid.

Example

This example displays a random item data from the combobox.

DGS = exports.dgs
function clientsideResourceStart ()
    local numberList = DGS:dgsCreateComboBox ( 10,270,150,30,"test",false )
    local item = DGS:dgsComboBoxAddItem ( numberList )
    local myItem = DGS:dgsComboBoxSetItemText ( numberList, item, tostring( math.random(0, 10) ^ 100 ) )
    DGS:dgsComboBoxSetItemData( numberList, item, "Test" )
    local myItemData = DGS:dgsComboBoxGetItemData( numberList, item )
    outputChatBox ( "My combobox item data: " .. myItemData )
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

Syntax

bool dgsComboBoxSetItemData ( element combobox, int itemIndex, mixed key, mixed data )

Required Arguments

  • combobox: the combobox containing the item you're interested in.
  • itemIndex: the item index of the item.
  • key: the key you wish to store the data under.
  • data: The value you wish to store.

Returns

Returns true if set successfully, false if one of the arguments was invalid.

Example

This example displays a random item data from the combobox.

DGS = exports.dgs
function clientsideResourceStart ()
    local numberList = DGS:dgsCreateComboBox ( 10,270,150,30,"test",false )
    local item = DGS:dgsComboBoxAddItem ( numberList )
    local myItem = DGS:dgsComboBoxSetItemText ( numberList, item, tostring( math.random(0, 10) ^ 100 ) )
    DGS:dgsComboBoxSetItemData( numberList, item, "myKey", "Test" )
    local myItemData = DGS:dgsComboBoxGetItemData( numberList, item, "myKey" )
    outputChatBox ( "My combobox item data: " .. myItemData )
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips