Add a vertical line (Right Border) to the gridcontrol header in devexpress)

Source: Internet
Author: User

Developed by winform, The gridcontrol control in devexpress is used. The default header is a 3D style. If you want to flat the display like the content and add a vertical line (Right Border ),
The nightmare started ..
After a burst of exploration, we found that the solution can be as follows:

1. Set the paintstylename attribute of the gridcontrol's gridview control to Web

2. Add the customdrawcolumnheader event to the gridview control of gridcontrol. The reference code is as follows:

Private void gridview1_mdrawcolumnheader (Object sender, columnheadercustomdraweventargs e) {If (E. column = NULL) return; E. painter. drawobject (E. info); Using (PEN p1 = new pen (color. fromargb (227,227,227), 2) {e. graphics. drawline (P1, E. bounds. X + E. bounds. width, E. bounds. y-2, E. bounds. X + E. bounds. width, E. bounds. Y + E. bounds. height + 2 );}}

Note: color. fromargb (227,227,227) is the color value of the vertical line.
At this time, if the bordercolor of the headerpanel under the appearance attribute in the gridview is set, there will be some gaps in the set color value.
Therefore, it is best to set the color in the event, and there is a little highlight, which should not be affected.

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.