GuiGridListGetRowCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Replace to predefined variables.)
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
This function returns the number of rows in a GUI grid list
__NOTOC__
This function returns the number of rows in a grid list.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int guiGridListGetRowCount ( element theElement )
int guiGridListGetRowCount ( element gridList )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Gridlist|GuiGridList]]:getRowCount|rowCount}}


===Required Arguments===  
===Required Arguments===  
*'''theElement:''' GUI grid list element pointer
*'''gridList:''' The grid list to get the number of rows from.


===Returns===
===Returns===
Returns an ''int'' - the number of rows if the function is successfull, ''false'' otherwise.
Returns the number of rows if the function is successful, ''false'' otherwise.


==Example==  
==Example==  
This example creates a gui grid list, fills it with server players and returns the number of rows (players) eventually
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 onClientResourceStart ()
function createPlayerList ()
         -- Create the grid list element
         --Create the grid list element
         local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )  
         local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
         -- Create a players column in the list
         --Create a players column in the list
         local column = guiGridListAddColumn( playerList, "Player", 0.85 )  
         local column = guiGridListAddColumn( playerList, "Player", 0.85 )
         if ( column ) then -- If the column was successfully created
         if ( column ) then --If the column has been created, fill it with players
                --Loop through adding players to the grid list
                 for id, player in ipairs(getElementsByType("player")) do
                 for id, playeritem in ipairs(getElementsByType("player")) do  
                         local row = guiGridListAddRow ( playerList )
                         local row = guiGridListAddRow ( playerList )
                         guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false )
                         guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
                 end
                 end
                 outputChatBox ( "Number of player list rows: "..guiGridListGetRowCount ( playerList ) )
                 outputChatBox ( "Number of player list rows: " .. guiGridListGetRowCount ( playerList ) )
         end
         end
end
end
</syntaxhighlight>
addEventHandler ( "onClientResourceStart", resourceRoot, onClientResourceStart )</syntaxhighlight>


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

Latest revision as of 09:18, 12 July 2023

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

Syntax

int guiGridListGetRowCount ( element gridList )

OOP Syntax Help! I don't understand this!

Method: GuiGridList:getRowCount(...)
Variable: .rowCount


Required Arguments

  • gridList: 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 onClientResourceStart ()
        -- Create the grid list element
        local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
        -- Create a players column in the list
        local column = guiGridListAddColumn( playerList, "Player", 0.85 ) 
        if ( column ) then -- If the column was successfully created
                --Loop through adding players to the grid list
                for id, playeritem in ipairs(getElementsByType("player")) do 
                        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", resourceRoot, onClientResourceStart )

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

Input

GUI