GetRowFromItemText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "This function enables you to get row from gridlist by using itemtext. ==Syntax== <syntaxhighlight lang="lua">int getRowFromItemText ( element gridList, string itemText [, int column] )</syntaxhighlight> ...")
 
No edit summary
Line 1: Line 1:
{{Useful Function}}
__NOTOC__
This function enables you to get row from gridlist by using itemtext.
This function enables you to get row from gridlist by using itemtext.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">int getRowFromItemText ( element gridList, string itemText [, int column] )</syntaxhighlight>
<syntaxhighlight lang="lua">int getRowFromItemText ( element gridList, string itemText [, int column] )</syntaxhighlight>
===Required Arguments===  
===Required Arguments===  
* '''gridList''': The gridlist you want to get the row from.
* '''gridList''': The gridlist you want to get the row from.
* '''itemText''': The itemtext of the row.
* '''itemText''': The itemtext of the row.
===Optional Arguments===
===Optional Arguments===
* '''column''': The column you want to check the itemtext on.
* '''column''': The column you want to check the itemtext on.
===Returns===
===Returns===
Returns row if successful, false otherwise.
Returns row if successful, false otherwise.

Revision as of 09:23, 24 March 2013


This function enables you to get row from gridlist by using itemtext.

Syntax

int getRowFromItemText ( element gridList, string itemText [, int column] )

Required Arguments

  • gridList: The gridlist you want to get the row from.
  • itemText: The itemtext of the row.

Optional Arguments

  • column: The column you want to check the itemtext on.

Returns

Returns row if successful, false otherwise.

Code

Click to collapse [-]
Function source
function getRowFromItemText ( list, name, colum )
	if ( isElement(list) ) and ( getElementType(list) == "gui-gridlist" ) ( type(name) == "string" ) then
		local colum = tonumber(colum) or 1
		local rows = guiGridListGetRowCount ( list ) - 1
		for i=0,rows do
			local text = guiGridListGetItemText ( list, i, colum )
			if ( text == name ) then
				return i
			end
		end
	end
	return false
end

Author: Bssol