Two knowledge points of cxgrid: Keep the column width and row coloring during design

Source: Internet
Author: User

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.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.