Home > Back-end >  How do I change the default border color?
How do I change the default border color?

Time:09-19



How do I change the default border color, color and DrawGrid form, to red, for example,
To change the control's border color is more, oneself one by one with Canvas painting too much trouble in the Paint, is there a more concise way?

CodePudding user response:

VCL should be more troublesome, such as modified source code to compile to join the project and related unit or custom controls,
Or see if there are any third party controls support beautification,
Or see if FMX library convenient point,
Or do as the Romans do,

CodePudding user response:

Well, I'm using the "Data Controls," below "TDBGrid control,
This control has a OnDrawColumnCel events,

My sample code, ADOQuery_department is ADO control that can be retrieved from the database data, DataSource_department is a data source control, DBGrid_department is to display controls,

But according to a column in the database data, to display the different font color and background color, or box,


Void __fastcall TForm_department: : DBGrid_departmentDrawColumnCell (TObject * Sender,
Const TRect & amp; The Rect, int DataCol TColumn * Column, TGridDrawState State)

{
Try
{
If (ADOQuery_department - & gt; FieldByName (" valid_flag ") - & gt; AsInteger==1)
{
//if the bank is normal department

//DBGrid_department - & gt; Canvas - & gt; Brush - & gt; Color=clRed;//background color
DBGrid_department - & gt; Canvas - & gt; The Font - & gt; Color=clBlack;//color words
DBGrid_department - & gt; Canvas - & gt; Pen - & gt; Color=clRed;//brush color
DBGrid_department - & gt; Canvas - & gt; MoveTo (the Rect. Left, the Rect. Bottom);//brush locate
DBGrid_department - & gt; Canvas - & gt; LineTo (the Rect. Right, the Rect. Bottom);//under the horizontal lines
DBGrid_department - & gt; Canvas - & gt; LineTo (the Rect. Right, the Rect. Top);//right horizontal lines
DBGrid_department - & gt; Canvas - & gt; LineTo (the Rect. Left, the Rect. Top);//horizontal lines
DBGrid_department - & gt; Canvas - & gt; LineTo (the Rect. Left, the Rect. Bottom);//left horizontal lines

}
The else
{
//if the bank is invalid department
//DBGrid_department - & gt; Canvas - & gt; Brush - & gt; Color=clRed;//background color
DBGrid_department - & gt; Canvas - & gt; The Font - & gt; Color=clBlue;//color words
}

DBGrid_department - & gt; DefaultDrawColumnCell (the Rect, DataCol, the Column, the State);
}
The catch (... )
{}
}
  • Related