Показать сообщение отдельно
  #2  
Старый 28.07.2011, 23:26
Аватар для angvelem
angvelem angvelem вне форума
.
 
Регистрация: 18.05.2011
Адрес: Омск
Сообщения: 3,970
Версия Delphi: 3,5,7,10,12,XE2
Репутация: выкл
По умолчанию

Попробуй так:
Код:
function IsCellSelected(StringGrid: TStringGrid; X, Y: Longint): Boolean;
begin
  Result := False;
  try
    if (X >= StringGrid.Selection.Left) and (X <= StringGrid.Selection.Right) and
      (Y >= StringGrid.Selection.Top) and (Y <= StringGrid.Selection.Bottom) then
      Result := True;
  except
  end;
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  I, J : Integer;
begin
  // заливаем
  for I := 0 to SG.ColCount - 1 do
    for J := 0 to SG.RowCount - 1 do
      SG.Cells[I, J] := Format('X=%d, Y=%d', [I, J]);
end;

procedure TForm2.Button2Click(Sender: TObject);
var
  I, J : Integer;
begin
  // чистим
  for I := 0 to SG.ColCount - 1 do
    for J := 0 to SG.RowCount - 1 do
       if IsCellSelected(SG, I, J) then
         SG.Cells[I, J] := ''
end;
__________________
Je venus de nulle part
55.026263 с.ш., 73.397636 в.д.
Ответить с цитированием