Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hide cols in StringGrid

Status
Not open for further replies.

DaZZleD

Programmer
Oct 21, 2003
886
US
is it possible to hide a column of a TStringGrid object? if yes, then how? (i want to have a unique number for each row - that I can use when I operate on the data of a row - that doesn't necessarily corespond to the row number of the selected row in the stringgrid. for example when i sort the rows of the grid on different criteria, these unique identifiers won't be the same with the row number where they appear. these identifiers would need to be hidden from display, but accessible from the code)

any help is appreciated!
Alex
 
I used a StringList to store the index corespondance for each of the rows of the grid. for example row number 52 has the unique number stored at position 52 of the StringList.
 
If you want to do it that way, fine with me. But a hidden column in a TStringGrid can be used in a similar way. Each column is a TStrings object, and a TStrings object has an IndexOf method you can use for finding a particular string.

I would say whichever way you go is more a matter of taste than of technique, as long as you never add or delete rows from the string grid and don't sort it either.

If you have to sort the string grid, or insert rows other than at the end, keeping the TStringList in synch with the grid may cause you some headache.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top