procedure TForm .FormCreate(Sender: TObject);
begin
StringGrid .Rows[ ].Strings[0] := 'This Row';
StringGrid .Cols[ ].Strings[0] := 'This Column';
end;function GetGridColumnByName(Grid : TStringGrid;
ColName : string): integer;
var
i : integer;
begin
for i := 0 to Grid.ColCount - do
if Grid.Rows[0].Strings[i] = ColName then begin
Result := i;
exit;
end;
Result := - ;
end;
function GetGridRowByName(Grid : TStringGrid;
RowName : string): integer;
var
i : integer;
begin
for i := 0 to Grid.RowCount - do
if Grid.Cols[0].Strings[i] = RowName then begin
Result := i;
exit;
end;
Result := - ;
end;
procedure TForm .Button Click(Sender: TObject);
var
Column : integer;
Row : integer;
begin
Column := GetGridColumnByName(StringGrid , 'This Column');
if Column = - then
ShowMessage('Column not found') else
ShowMessage('Column found at ' + IntToStr(Column));
Row := GetGridRowByName(StringGrid , 'This Row');
if Row = - then
ShowMessage('Row not found') else
ShowMessage('Row found at ' + IntToStr(Row));
end;