Dbgrid1.defadrawcolumncell (Rect, DataCol, Column, State );
The above two methods highlight the Column Display Effect.
3. Highlight the selected row in red in the data grid.
Set the dgRowSelect attribute in the Options attribute of the DbGrid control to true, and the Color attribute to clAqua (background Color). Write the following code in the DbGrid DrawColumnCell event:
If (State = [gdSelected]) or (State = [gdSelected, gdFocused]) then
DbGrid1.Canvas. Brush. color: = clRed; file: // The current row is displayed in red. Other rows use the light green background.
DbGrid1.Canvas. pen. mode: = pmmask;
Dbgrid1.defadrawcolumncell (Rect, DataCol, Column, State );
4. Zebra Effect of line highlighting: not only highlight the current row, but also distinguish different columns (fields ).
File: // other attributes are set to the same as 3. Modify the above Code:
If (State = [gdSelected]) or (State = [gdSelected, gdFocused]) then
Begin
Case DataCol Mod 2 = 0
True: DbGrid1.Canvas. Brush. color: = clRed; file: // red is displayed for the even column of the currently selected row.
False: DbGrid1.Canvas. Brush. color: = clblue; file: // the odd sequence of the currently selected row is blue.
End;
DbGrid1.Canvas. pen. mode: = pmmask;
Dbgrid1.defadrawcolumncell (Rect, DataCol, Column, State );
End;
5. Horizontal zebra crossings, highlighted in red at the same time.
File: // other attributes are set to the same as 3. Modify the above Code:
Case Table1.RecNo mod 2 = 0 of file: // judge based on the record number of the dataset
True: DbGrid1.Canvas. Brush. color: = clAqua; file: // displays even rows in light green.
False: DbGrid1.Canvas. Brush. color: = clblue; file: // the odd number of rows in blue.
End;
If (State = [gdSelected]) or (State = [gdSelected, gdFocused]) then file: // display the selected row in red
DbGrid1.Canvas. Brush. color: = clRed;
DbGrid1.Canvas. pen. mode: = pmMask;
Dbgrid1.defadrawcolumncell (Rect, DataCol, Column, State );
6. Bidirectional zebra effect: select different colors for the selected lines and use vertical zebra effect to distinguish different columns.
File: // other attributes are set to the same as 3. Modify the above Code:
Case Table1.RecNo mod 2 = 0 of file: // judge based on the record number of the dataset
True: DbGrid1.Canvas. Brush. color: = clAqua; file: // displays even rows in light green.
False: DbGrid1.Canvas. Brush. color: = clblue; file: // the odd number of rows in blue.
End;
If (State = [gdSelected]) or (State = [gdSelected, gdFocused]) then
Case DataCol mod 2 = 0
True: DbGrid1.Canvas. Brush. color: = clRed; file: // The even column of the currently selected row is in red.
False: DbGrid1.Canvas. Brush. color: = clGreen; file: // the odd sequence of the currently selected row in green.
End;
DbGrid1.Canvas. pen. mode: = pmMask;
Dbgrid1.defadrawcolumncell (Rect, DataCol, Column, State );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service