Arsip: [ask] Button dalam DBgrid

 
user image
more 11 years ago

kepiss

Para master adakah yang bisa membantu saya... memasukan Tbutton dalam DB grid... pernah nyoba...dapet code di internet..tapi g bisa...

// pembutan unit 
unit GambarDBgrid;
interface
uses windows,Messages,Sysutils,Classes,Graphics,
Controls,Forms,Grids,Dbgrids;
Type
  TGambarDBgrid = Class(TDbgrid);
  private
    FRowHeight:integer;
    Protected
    Procedure
      SetRowHeight(Value:integer);
      Public
      Function CellRect(Acol,Arow :LongInt):Trect;ReintRoduce;
      property Row;
      Property Col;
      Published
      Property RowHieght:integer
      Read FRowHieght write SetRowHieght;
    end;
    Procedure Register;
implementation
uses DB;
Function TGambarDBgrid.CellRect(Acol,Arow:Longint):Trect;
begin
  result:=inherited CellRect(Acol,Arow);
end;
Procedure TGambarDBgrid.setRowHieght(Value:integer);
begin
  if FRowHieght <> value then begin
    FRowHieght :=Value;
    DefaultRowHieght :=FRowHieght;
    if self.datalink.active then begin
      Perform(WM_SIZE,0,0);
    end;
  end;
end;
procedure Register;
begin
  RegisterComponents('Custom',[TGambarDBGrid]);
end;

//---------------------------Menggunakan unitnya
procedure TFgrid.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
  var
    Datarect:Trect;
 Begin
   // Place the button in the first column.
   If (Column.Index = 0) Then Begin
      With ButtonDBGrid1 Do Begin
         DataRect := CellRect(Column.Index,Row);
      End;
   // Assign the button's parent to the grid.
   If SpeedButton1.Parent <> ButtonDBGrid1 Then
      SpeedButton1.Parent := ButtonDBGrid1 ;
   // Set the button's coordinates.
   // In this case, right justify the button.
   If SpeedButton1.Left <> (DataRect.Right - SpeedButton1.Width) Then
      SpeedButton1.Left := (DataRect.Right - SpeedButton1.Width) ;
   If (SpeedButton1.Top <> DataRect.Top) Then
      SpeedButton1.Top := DataRect.Top ;
   // Make sure the button's height fits in row.
   If (SpeedButton1.Height <> (DataRect.Bottom-DataRect.Top)) Then
      SpeedButton1.Height := (DataRect.Bottom-DataRect.Top);
   End;
End;
adakah cara lain....selain di atas...hehheh....
user image
more 11 years ago

denmasdanang

:kepiss bisa pakai ehlib, lengkap
user image
more 11 years ago

kepiss

@denmasdanang: :kepiss bisa pakai ehlib, lengkap
Ketemu lagi denmasdanang....hehe. ehlib....itu komponent ya mas???
user image
more 11 years ago

denmasdanang

iya
user image
more 11 years ago

kepiss

@denmasdanang: iya
oke mas.....baru di download....makasih wat ilmunya,...
user image
more 11 years ago

denmasdanang

ok. kalau sudah kasih skrinsut nya dong, pakai ehlib yang mas maksud seperti apa? :D
user image
more 11 years ago

kepiss

ne mas hasilnya....baru coba coba....belum bisa maksimalin kegunaanya
user image
more 11 years ago

denmasdanang

:idea: :idea: :idea: :idea: :idea: :idea: :idea: :idea: :idea: sip
more ...
  • Pages:
  • 1
Share to
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com