PDA

View Full Version : دابل کلیک کردن روی یک سطر DBGrid و قرمز شدن آن سطر



farzane_fn
جمعه 01 آبان 1388, 15:58 عصر
دوستای گلم سلام.یه دی بی گرید داریم که کلی اطلاعات توش هست- اطلاعات داخل اون از سرچ کردن توی یک بانک بدست آمده - حالا می خوایم اگه روی یکی از سطرهای این دی بی گرید دابل کلیک کنیم اون سطر قرمز بشه.چی کار باید بکنیم؟ لطفا راهنمایی کنید..

merced
جمعه 01 آبان 1388, 16:46 عصر
دو راه هست يه فيلد boolean در نظر بگير كه با دابل كليك True يا False بشه
يا يك آرايه پويا از BookMark ها بساز
(بستگي داره كه اين تعيير رنگ دائمي هست يا موقت)

حالا با كد ساده اي مي توني تو رويداد OnDrawcell گريد اين كار رو انجام بدي

راه ديگه هم Multi Select كردن DBGrid هست كه ...

khorsandreza
جمعه 01 آبان 1388, 17:09 عصر
از نمونه داده شده استفاده کنيد






Try
With TDBGrid(Sender) do
Begin
{If (ds_AllListQ.DataSet.RecNo MOD 2)=1 Then
Canvas.Brush.Color := Canvas_Color1
Else Canvas.Brush.Color := Canvas_Color2; }
Canvas.Font.Color := clBlack ;
if gdSelected in State then
Begin
Canvas.Brush.Color := clNavy;//$0079FFFF;// clPurple;
Canvas.Font.Size := 10;
Canvas.Font.Style := [fsBold];
Canvas.Font.Color := $0079FFFF ;
End ;
if SelectedRows.IndexOf(ds_AllListQ.DataSet.Bookmark) >= 0 then
begin
Canvas.Brush.Color := clPurple;
Canvas.Font.Size := 10;
Canvas.Font.Style := [];
Canvas.Font.Color := clWindow;// $0079FFFF ;
end;
if (AllListQOZVYAT.AsInteger IN[14,15,16,54]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clRed;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'X');
End;
if (AllListQOZVYAT.AsInteger IN[88]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clGreen;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'B');
End;
if (AllListQOZVYAT.AsInteger IN[82]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clOlive;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'X');
End;
if (AllListQOZVYAT.AsInteger IN[61,62,63]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clYellow;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'S');
End;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
End;
Except
End;



در Eveant ديتا گريد بنويسيد