Home > Back-end > I want to judge the comparison of three column value judgment conditions after the background color
I want to judge the comparison of three column value judgment conditions after the background color
Time:10-12
I want to judge the comparison of three column value judgment conditions after the background color of the change, the following, I don't know where there is a mistake? In addition, also note what will demonstrate success? I am a novice so, please detail point, thank you! Procedure TForm17. DBGrid1DrawColumnCell (Sender: TObject; Const the Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); The begin If ADOQuery1. FieldByName (' data ') AsString & lt; ADOQuery1. FieldByName (' minimum ') AsString then DBGrid1. Canvas. Brush. Color:=clred; DBGrid1. DefaultDrawColumnCell (the Rect, DataCol, the Column, the State); If ADOQuery1. FieldByName (' data ') AsString & gt; ADOQuery1. FieldByName (' maximum). AsString then DBGrid1. Canvas. Brush. Color:=clred; DBGrid1. DefaultDrawColumnCell (the Rect, DataCol, the Column, the State); end;
CodePudding user response:
When "field 2" less than "field 1" value, it shows red, when the "field 2" is more than "field 3", it shows yellow, Three fields are ADOQuery1 query value, Ask how your code, thank you detail more!
CodePudding user response:
procedure TForm7. DBGrid1DrawColumnCell (Sender: TObject; Const the Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); The begin With DBGrid1. The DataSource. The DataSet do begin If FieldByName (' field 2.) AsInteger & lt; FieldByName (' field 1.) AsInteger then DBGrid1. Canvas. Brush. Color:=clred Else if FieldByName (' field 2.) AsInteger & gt; FieldByName (' field 3.) AsInteger then DBGrid1. Canvas. Brush. Color:=clYellow The else DBGrid1. Canvas. Brush. Color:=clWindow; end; DBGrid1. Canvas. FillRect (the Rect); If (State=[gdSelected]) or (State=[gdSelected gdFocused]) then DBGrid1. Canvas. The font color:=clBlue The else DBGrid1. Canvas. The font color:=clblack; DBGrid1. DefaultDrawColumnCell (the Rect, DataCol, the Column, the State); end;
CodePudding user response:
When "field 2" less than "field 1" value, it shows red, when the "field 2" is more than "field 3", it shows yellow, "Field 1" "field 2" "field 3" from the three fields are ADOQuery1 calculated value, upstairs can change, use ADOQuery, Ask how your code, thank you detail more!