1. Maintain proper column width and fill the entire area
By default, a column in cxgrid has a minwidth attribute, which is 20 by default and is changed to 0. Set columnautowidth of cxgridview to true. In this way, the column width will be adjusted based on the design Length Based on the whole area. The length will not be changed randomly after dataset open.
2. line-by-line color change
The coloring like this cannot be written in the griddrawcell event.Code:
{If aviewinfo. recordviewinfo. Index mod 2 = 0 then
Begin
Acanvas. Canvas. Brush. Color: = RGB (252,240,235 );
Acanvas. Font. Color: = clblack;
End
Else
Begin
Acanvas. Canvas. Brush. Color: = clwhite;
Acanvas. Font. Color: = clblack;
End;
If aviewinfo. Selected then
Begin
Acanvas. Canvas. Brush. Color: = clmenuhighlight;
Acanvas. Font. Color: = clwhite;
End ;}
There is a problem with this coloring. If the number of records exceeds one screen, you will find that the coloring is not a line by line, but a color when you move the mouse down. Because griddrawcell can only process the visible part.
Cxgridview has three styles that can be easily set without any code. The three styles are:
Contenteven (even row style), contentodd (odd row style), and selection (selected row style ). These three styles can be used to set the perfect line coloring effect.