delphi4arab منتديات دلفي للعرب
اداخال ايقونتين في dbgrid حسب شرطين true or false - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : اداخال ايقونتين في dbgrid حسب شرطين true or false (/showthread.php?tid=9542)



اداخال ايقونتين في dbgrid حسب شرطين true or false - Med-01 - 21-06-2018

السلام عليكم ورحمة الله وبركاته

اريد اضافة حقل بجانب حقل من نوع bolean حيث يتم ادخال ايقونة خضرا في امام true وحمراء امام false

كما هنا موجود

[صورة: capture09.png]
باعتماد على

[صورة: capture02.png]
هذا هو جدولي

[img]blob:https://imgur.com/9b9b375b-bef2-442c-a2be-cf9ce670a43f[/img][صورة: W3J9LJP.png]

شكرااا وجزاكم الله خيراااا


[img]blob:https://imgur.com/9b9b375b-bef2-442c-a2be-cf9ce670a43f[/img][img]blob:https://imgur.com/9b9b375b-bef2-442c-a2be-cf9ce670a43f[/img]
[img]blob:https://imgur.com/9b9b375b-bef2-442c-a2be-cf9ce670a43f[/img]



RE: اداخال ايقونتين في dbgrid حسب شرطين true or false - Delphi4Us - 21-06-2018

PHP كود :
type
  TDBGrid 
= Class(DBGrids.TDBGrid)
 
 private
    FIcon
:TIcon;
 
   FImageList: TImageList;
 
   procedure SetImageList(const Value: TImageList);
 
   Destructor Destroy;override;
 
 published
    procedure DrawCell
(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
 
   Property Imagelist: TImageList read FImageList Write SetImageList;
 
 End;

 
 TForm2 = class(TForm)
 
   .......

implementation


{$R *.dfm}
{ 
TDBGrid }

destructor TDBGrid.Destroy;
begin
  if Assigned
(FIcon) then FIcon.Free;
 
 inherited;
end;

procedure TDBGrid.SetImageList(const Value: TImageList);
begin
  FImageList 
:= Value;
 
 FreeAndNil(FIcon);
 
 if Assigned(FImageList) then
    begin
    FIcon 
:= TIcon.Create;
 
   FImageList.GetIcon(0, FIcon);
 
   end;
end;

procedure TDBGrid.DrawCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState);
var
 
 L_Col: Integer;
begin
  if dgIndicator in Options then
    L_Col 
:= ACol - 1
  else
    L_Col 
:= ACol;

 
 inherited;
 
 if Assigned(FIcon) and (L_Col > -1) and (ARow = 0) and (Columns[L_Col].FieldName = 'ID') and (gdFixed in AState) then
  begin
      Canvas
.Draw(ARect.Right - 18, ARect.Bottom - 18, FIcon);
 
     //FImagelist.Draw(Canvas,ARect.Right - 18, ARect.Bottom - 18,0); // would cause more flickering
 
 end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  DBGrid1
.DoubleBuffered := true;
 
 DBGrid1.Imagelist := ImageList1;
 
 ReportMemoryLeaksOnShutDown := true;
end; 



RE: اداخال ايقونتين في dbgrid حسب شرطين true or false - bouh25 - 21-06-2018

PHP كود :
procedure TFEmpr.sDBGrid3DrawColumnCell(Sender: TObject; const Rect: TRect;
 
DataCol: Integer; Column: TColumn; State: TGridDrawState);



begin
  if Column
.Field=datam.Temprunterempr then
 begin
   sDBGrid3
.Canvas.FillRect(Rect);
 
  ImageList1.Draw(sDBGrid3.Canvas,Rect.Left+2,Rect.Top+2,0);
 
  if datam.Temprunterempr.AsBoolean then
     ImageList1
.Draw(sDBGrid3.Canvas,Rect.Left+2,Rect.Top+2,2)
 
  else
 
    ImageList1.Draw(sDBGrid3.Canvas,Rect.Left+2,Rect.Top+2,1);
 
end;
end; 



RE: اداخال ايقونتين في dbgrid حسب شرطين true or false - rezki_z - 25-06-2018

على حسب مااتذكر انك لاتحتاج الى كل هذا الكود لقد مررت على dbgrid فيها هذه الخاصية مباشرة وهذه الخاصية تجدها في dbgrid الغالية الثمن وانا لن اكذب عليك حملتها ****واستعملتها وروعة فانصحك بتجريب dbgrid الغالية الثمن مثل tms component و غيرها فلا تحتاج الى كل هذا الكود والله الموفق


RE: اداخال ايقونتين في dbgrid حسب شرطين true or false - Med-01 - 30-06-2018

تم بواسطة Delphi4Us لكن عدلت على الكود قليلا
شكراا