Статьи
|
Как в ячейку(столбец) StringGrid (подобно Columns ButtonStyle в DBGrid) вставить кнопку с раскрывающимся списком в виде StringGrid
На форму кладем StringGrid, ComboBox и SpeedButton.
procedure TForm3.StringGrid1SelectCell(Sender: TObject;
ACol, ARow: Integer; var CanSelect: Boolean);
var R : TRect;
begin
if ((ACol = 1) AND (ARow <> 0)) then begin
//Вставка ComboBox (delphikingdom) во 2-й стобец
R := StringGrid1.CellRect(ACol, ARow);
R.Left := R.Left + StringGrid1.Left;
R.Right := R.Right + StringGrid1.Left;
R.Top := R.Top + StringGrid1.Top;
R.Bottom := R.Bottom + StringGrid1.Top;
ComboBox4.Top := R.Top + 1;
ComboBox4.Left := R.Left + 1;
ComboBox4.Width := (R.Right + 1) - Kvadr.Left;
ComboBox4.Height := (R.Bottom + 1) - Kvadr.Top;
ComboBox4.Visible := True;
ComboBox4.SetFocus;
SpeedButton3.Visible := False;
end
else if ((ACol = 2) AND (ARow <> 0)) then begin
//Вставка SpeedButton в 3-й стобец
ComboBox4.Visible := False;
R: = StringGrid1.CellRect(ACol, ARow);
SpeedButton3.Top := R.Bottom - SpeedButton3.Height - 1;
SpeedButton3.Left := R.Right - SpeedButton3.Width - 1;
SpeedButton3.Parent := StringGrid1;
SpeedButton3.Visible := True;
end
else begin
ComboBox4.Visible := False;
SpeedButton3.Visible := False;
end;
CanSelect := True;
end;
|