Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#2

Re: Zellen nur innerhalb einer Zeile markieren (Stringgrid)

  Alt 5. Nov 2005, 15:36
Herzlich willkommen in der Delphi-PRAXiS, White Rabbit.

OnSelectCell() scheint mir weniger geeignet. Schau dir mal diesen Code an:

Delphi-Quellcode:
procedure TDemoForm.StringGridClick(Sender: TObject);
var
  p: TPoint;
  gr: TGridRect;
  iCol, iRow: integer;
begin
  with StringGrid do
  begin
    p := ScreenToClient(Mouse.CursorPos);
    MouseToCell(p.X, p.Y, iCol, iRow);
    if (iCol < FixedCols) or (iRow < FixedRows) then
      Exit;
    if iRow <> Row then
    begin
      gr.Left := iCol;
      gr.Right := iCol;
      gr.Top := iRow;
      gr.Bottom := iRow;
      Selection := gr;
    end;
  end;
end;
Grüße vom marabu
  Mit Zitat antworten Zitat