Grid.GetColumnCount

number Grid.GetColumnCount ( 

string ObjectName )

Example 1

-- Get the total Columns in the grid
ColumnCount = Grid.GetColumnCount("Grid1");

-- loop through each Column and add a numbered message
for i = 0, ColumnCount do
     -- Set the text of the Columns
     Grid.SetCellText("Grid1", 0, i, "Stats "..i, true);
end

-- Set auto size for all columns
Grid.AutoSizeColumns("Grid1", GVS_DEFAULT, true);

Labels all columns in the grid to 'Stats #' then resizes the Columns to fit the text

Example 2

-- Get the number of columns
totalColumns = Grid.GetColumnCount("Grid1");
-- Delete the rightmost column
Grid.DeleteColumn("Grid1", totalColumns - 1, true);
-- note: the -1 is because the columns in the grid are zero based.

Deletes the rightmost column from the grid

See also:  Related Actions