GuiGridListGetRowCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 16: Line 16:
==Example==  
==Example==  
This example creates a gui grid list, fills it with the names of the connected players and prints the number of rows (players) in the chatbox.
This example creates a gui grid list, fills it with the names of the connected players and prints the number of rows (players) in the chatbox.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">function clientsideResourceStart ()
function createPlayerList ()
         local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list element
        -- Create the grid list element
         local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a players column in the list
         local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
         if ( column ) then -- If the column was successfully created
        -- Create a players column in the list
                 for id, playeritem in ipairs(getElementsByType("player")) do --Loop through adding players to the grid list
         local column = guiGridListAddColumn( playerList, "Player", 0.85 )
         if ( column ) then       -- If the column has been created, fill it with players
                 for id, playeritem in ipairs(getElementsByType("player")) do
                         local row = guiGridListAddRow ( playerList )
                         local row = guiGridListAddRow ( playerList )
                         guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
                         guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
Line 30: Line 27:
         end
         end
end
end
</syntaxhighlight>
addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )</syntaxhighlight>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}

Revision as of 07:11, 8 October 2007

This function returns the number of rows in a grid list.

Syntax

int guiGridListGetRowCount ( element theList )

Required Arguments

  • theList: The grid list to get the number of rows from.

Returns

Returns the number of rows if the function is successful, false otherwise.

Example

This example creates a gui grid list, fills it with the names of the connected players and prints the number of rows (players) in the chatbox.

function clientsideResourceStart ()
        local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list element
        local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a players column in the list
        if ( column ) then -- If the column was successfully created
                for id, playeritem in ipairs(getElementsByType("player")) do --Loop through adding players to the grid list
                        local row = guiGridListAddRow ( playerList )
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
                end
                outputChatBox ( "Number of player list rows: " .. guiGridListGetRowCount ( playerList ) )
        end
end
addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows