What is the best method for locating a column index by name.
ColumnByHeader doesn't seem to find hidden columns even though they have
a header. I could not find any documentation on this method. I want
to be able to get the column index by using the Column Name.
something like GetColumnIndexByName('NameOfColumn') would be nice.
Thanks
Gary Conley
TAdvColumnGrid has a function grid.ColumnByName()
If you use TAdvStringGrid, a column does not have a name, it has an index.
You can use grid.ColumnAtPosition() to get the column index at a specific position in the grid or grid.ColumnPosition() to find the position of a column with a given index.
You can use grid.ColumnAtPosition() to get the column index at a specific position in the grid or grid.ColumnPosition() to find the position of a column with a given index.
Thank you Bruno - Using a AdvColumnGrid then I could do something like
MyColIndex := Grid.ColumnByName('ColName').Index;
Does it matter if Columns are hidden or if their Size is 0?
In TAdvColumnGrid using grid.ColumnByName() should work irrespective of a column being hidden or with width = 0.