GuiGridListClear: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(6 intermediate revisions by 5 users not shown)
Line 6: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiGridListClear ( element gridList )
bool guiGridListClear ( element gridList )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Gridlist|GuiGridList]]:clear}}


===Required Arguments===  
===Required Arguments===  
Line 15: Line 16:


==Example==  
==Example==  
This example creates a grid list, puts an item with the text "Hello world" in it and clears the grid list after 5 seconds.
This creates a player list and then clears it when a button is clicked:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Create the grid list element
-- create the grid list
local testList = guiCreateGridList ( 0.45, 0.45, 0.10, 0.10, true )
local playerList = guiCreateGridList(0.80, 0.40, 0.15, 0.35, true)
-- Create a column in the list and add a row with "Hello world" text
guiGridListAddColumn(playerList, "#", 0.15)
local column = guiGridListAddColumn( testList, "test", 0.85 )
guiGridListAddColumn(playerList, "Player", 0.75)
guiGridListSetItemText ( testList, guiGridListAddRow ( testList ), column, "Hello World", false, false )
 
-- Set a timer to clear the grid list in 5 seconds
-- fill the grid list with player names
setTimer ( guiGridListClear, 5000, 1, testList )
for index, player in ipairs(getElementsByType("player")) do
    guiGridListAddRow(playerList, index, getPlayerName(player))
end
 
-- create a button to clear the grid list
local clearButton = guiCreateButton(0.80, 0.30, 0.15, 0.05, "Clear list", true)
 
-- when the button is clicked, clear the grid list
addEventHandler("onClientGUIClick", clearButton, function()
    guiGridListClear(playerList)
end)
</syntaxhighlight>
</syntaxhighlight>


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

Latest revision as of 17:47, 22 December 2022

This function clears all the data from a grid list.

Syntax

bool guiGridListClear ( element gridList )

OOP Syntax Help! I don't understand this!

Method: GuiGridList:clear(...)


Required Arguments

  • gridList: The grid list element to be cleared

Returns

Returns true if the grid list element is valid and has been cleared successfully, false otherwise.

Example

This creates a player list and then clears it when a button is clicked:

-- create the grid list
local playerList = guiCreateGridList(0.80, 0.40, 0.15, 0.35, true)
guiGridListAddColumn(playerList, "#", 0.15)
guiGridListAddColumn(playerList, "Player", 0.75)

-- fill the grid list with player names
for index, player in ipairs(getElementsByType("player")) do
    guiGridListAddRow(playerList, index, getPlayerName(player))
end

-- create a button to clear the grid list
local clearButton = guiCreateButton(0.80, 0.30, 0.15, 0.05, "Clear list", true)

-- when the button is clicked, clear the grid list
addEventHandler("onClientGUIClick", clearButton, function()
    guiGridListClear(playerList)
end)

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