DgsGridListAutoSizeColumn

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

This allows you to automatically size a column to display everything in it correctly, with the most minimal width.

Syntax

bool dgsGridListAutoSizeColumn ( element gridList, int columnIndex [, float additionalLength, bool relative, bool isByItem ] )

Required Arguments

  • gridList: The dgs grid list element where the column is located.
  • columnIndex: The ID of the column you want to be auto-sized.

Optional Arguments

  • additionalLength: A float of the addition length which will be added into the calculated width.
  • relative: A bool indicates whether the additional length is relative to the width of the grid list or just absolute pixels.
  • isByItem: A bool indicates whether the column width is calculated refer to item text or column text.

Returns

Returns true if the column was auto-sized, false otherwise.

Example

This example creates a random list of numbers of various lengths. This function is used to adjust the width to display them all.

DGS = exports.dgs

function clientsideResourceStart ()
    local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) --Create a gridlist
    local column = DGS:dgsGridListAddColumn( numberList, "Column Title", 0.85 ) --Create a column on the gridlist
    if ( column ) then --If the column was created successfully
        local count = 0 -- Set the varible 'count' to the value 0
        while count <= 10 do --Loop through 10 times adding random numbers in rows for the column
            local row = DGS:dgsGridListAddRow ( numberList )
            DGS:dgsGridListSetItemText ( numberList, row, column, tostring(math.random(0, 10) ^ 100), false, false )
            count = count + 1
        end
        DGS:dgsGridListAutoSizeColumn ( numberList, column ) --After the numbers are added in rows, perform auto sizing on the column
    end
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