October 20th, 2004, 06:03 PM
Pretty easy actually. Note that the StringGrid has a property called Cols which returns a specific column as a TStrings. It also has a property called Rows, that returns a specific row as a TStrings object. Either way, a TStrings has an IndexOf() method to find a string within it. So, here's our method:
1. Go through all the columns of the stringgrid using the Cols property.
2. For each one, use IndexOf() to see if the string exists in this column. If it does, this is the row position of the item.
nCol : integer;
nRow : integer;
for nCol := 1 to StringGrid1.ColCount - 1 do
nRow := StringGrid1.Cols[nCol].IndexOf('47');
if (nRow > -1) then
ShowMessage('Found it at Column: ' + IntToStr(nCol) + ' and Row: ' + IntToStr(nRow));
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne