DBGRID unit painting circle

xiaoxiao2021-03-05  25

Procedure TFORM1.DBGRID1DRAWCOLUMNCELL (Sender: Tobject; Const Rect: TRECT;

Datacol: Integer; Column: Tcolumn; State: TgriddrawState;

VAR

String;

Begin

TDBGRID (Sender) .defaultdrawColumnCell (Rect, Datacol, Column, State);

S: = column.field.displaytext;

IF (Column.fieldName = 'fax') and (length (s) <10) THEN

Begin

With tdbgrid (sender) .canvas do

Begin

Pen.color: = CLRED;

Arc (Rect.Lep, Rect.top, Rect.right, Rect.bottom, Rect.Left, Rect.top, Rect.Lep, Rect.top);

END;

END;

END;

Direct painting arc is OK, this method is just to provide a reference:

Procedure TFORM1.DBGRID1DRAWCOLUMNCELL (Sender: Tobject; Const Rect: TRECT;

Datacol: Integer; Column: Tcolumn; State: TgriddrawState;

Const

Flags: array [talignment] of dword = (DT_LEFT, DT_RIGHT, DT_CENTER);

VAR

String;

R: TRECT;

Begin

TDBGRID (Sender) .defaultdrawColumnCell (Rect, Datacol, Column, State);

S: = column.field.displaytext;

R: = RECT;

IF (Column.fieldName = 'fax') and (length (s) <10) THEN

Begin

With tdbgrid (sender) .canvas do

Begin

Pen.color: = CLRED;

RoundRect (Rect.Lep, Rect.Top, Rect.right, Rect.bottom, Rect.Lep, Rect.top);

DrawText (Handle, Pchar (s), Length (S), R, Flags [Column.Alignment] or DT_VCenter);

END;

END;

END;

ByType, used to determine a CHAR is a single letter, or a double-byte of the front one or the latter one.

MBSINGLEBYTE single letter

Mbleadbyte double byte first

Mbtrailbyte double byte second bit

Extractstrings, split string

转载请注明原文地址:https://www.9cbs.com/read-36006.html

New Post(0)