Italian community of Lazarus and Free Pascal
Programmazione => Generale => Topic aperto da: Maverich - Aprile 27, 2012, 10:10:13 pm
-
scopo : creare una nuova griglia , al click sul pulsante
inserisco un TSpeedButton nel Form
nell'evento OnDrawColumnCell
if (gdFocused in State) then
begin
SpeedButton1.Visible := False;
if (Column.Field.FieldName = 'DETTAGLI') then
begin
SpeedButton1.Left := DBGrid1.Left + Rect.Left + 2;
SpeedButton1.Top := DBGrid1.Top + Rect.Top + 2;
SpeedButton1.Width := 25; //Rect.Right - Rect.Left;
SpeedButton1.Height := Rect.Bottom - Rect.Top;
SpeedButton1.Visible := True;
end;
non vedo il TSpeedButton nella griglia;
se modifico cosi'
SpeedButton1.Left := Rect.Left + 2;
SpeedButton1.Top := Rect.Top + 2;
vedo il TSpeedButton che si muove ma fuori dalla griglia;
//---- a parte la differenza di componente
//grdProtocollo e' un JvDBGrid (componente Jedi) ma deriva sempre da DBGrid
Questo funziona in Delphi
if (gdFocused in State) then
begin
if (Column.Field.FieldName = 'DETTAGLI') then
begin
JvDBComboEdit1.Left := Rect.Left + grdProtocollo.Left + 2;
JvDBComboEdit1.Top := Rect.Top + grdProtocollo.top + 2;
JvDBComboEdit1.Width := 25; //Rect.Right - Rect.Left;
JvDBComboEdit1.Height := Rect.Bottom - Rect.Top;
JvDBComboEdit1.Visible := True;
end
end
-
Io la butto lì.
Istanzia il bottone a runtime.
Prova a impostare il Parent = Griglia.
Al massimo imposti il bounds del bottone al rettangolo che ti viene passato ;)
-
e' bastato aggiungere il Parent :-[
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
SpeedButton1.Visible := False;
if (Column.Field.FieldName = DETTAGLI') then
begin
SpeedButton1.Parent := DBGrid1;
SpeedButton1.Top := Rect.Top;
SpeedButton1.Left := Rect.Left;
SpeedButton1.Visible := True;
end;
end;
end;
-
Felice di essere stato d'aiuto.