Раскрывающийся список в StringGrid
Добавлено: 11 окт 2005, 14:08
Подскажите, как в ячейку(столбец) StringGrid (на подобии Columns ButtonStyle в DBGrid) вставить кнопку с раскрывающимся списком в виде StringGrid?
Код: Выделить всё
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;
Бррр-р-р.... Так Вы в ячейку StringGrid вкладываете выпадающий StringGrid?т.к. в этом случае длина раскрывающейся StringGrid (по нажатии кнопки ComboBox) будет ограничена длиной ComboBox, т.е. длиной ячейки.