DgsGridListSetItemImage: Difference between revisions

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


==Example==
==Example==
This example displays a random item data from the gridlist.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
function clientsideResourceStart ()
texture = dxCreateTexture("image.png") -- put your texture element here
    local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
 
    local column = DGS:dgsGridListAddColumn ( numberList, "Column Title", 0.85 )
gridlist = DGS:dgsCreateGridList(300,200,300,400,false)
    if ( column ) then
DGS:dgsSetProperty(gridlist,"rowHeight",30) -- make it thicker to see the image clearer
        local row = DGS:dgsGridListAddRow ( numberList )
DGS:dgsGridListAddColumn(gridlist,"Country",0.2)
        local myItem = DGS:dgsGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) ^ 100 ) )
DGS:dgsGridListAddColumn(gridlist,"ID",0.7)
        DGS:dgsGridListSetItemData ( numberList, row, column, "Test" )
for i=1,10 do
        local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column )
local row = DGS:dgsGridListAddRow(gridlist)
        outputChatBox ( "My gridlist item data: " .. myItemData )
DGS:dgsGridListSetItemText(gridlist,row,2,tostring(i))
    end
DGS:dgsGridListSetItemImage(gridlist,row,1,texture,_,10,5,25,20)
end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{DGSFUNCTIONS}}
{{DGSFUNCTIONS}}

Revision as of 13:03, 24 February 2018

This function sets the image on a grid list item.

Syntax

bool dgsGridListSetItemImage( element gridList, int rowIndex, int columnIndex, element texture [, int color = 0xFFFFFFFF, float offsetX = 0, float offsetY = 0, float width, float height)
Item Image

Required Arguments

  • gridList: the grid list containing the item you're interested in.
  • rowIndex: An integer of the row index of the item.
  • columnIndex: An integer of the column index of the item.
  • texture: A texture element of the item you want to set.

Optional Arguments

  • color: An integer of the color of the texture.
  • offsetX : A float of the 2D X offset of the image of the item.
  • offsetY : A float of the 2D Y offset of the image of the item.
  • width: A float of the width of the image of the item.
  • height: A float of the height of the image of the item.

Returns

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

Example

DGS = exports.dgs
texture = dxCreateTexture("image.png") -- put your texture element here

gridlist = DGS:dgsCreateGridList(300,200,300,400,false)
DGS:dgsSetProperty(gridlist,"rowHeight",30) -- make it thicker to see the image clearer
DGS:dgsGridListAddColumn(gridlist,"Country",0.2)
DGS:dgsGridListAddColumn(gridlist,"ID",0.7)
for i=1,10 do
	local row = DGS:dgsGridListAddRow(gridlist)
	DGS:dgsGridListSetItemText(gridlist,row,2,tostring(i))
	DGS:dgsGridListSetItemImage(gridlist,row,1,texture,_,10,5,25,20)
end

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