C # WinForm DataGridView Rowheader Ways to add Row headers

Source: Internet
Author: User

        #region Write line number event        // Select Rowpostpaint event on DataGridView Control        privatevoid dgvjointlist_rowpostpaint (object  sender, Datagridviewrowpostpainteventargs e)        {            ( DataGridView) sender). Fillrowheaderindex (e);        }         #endregion
        #regionCommon methods for adding row headers used in the Rowpostpaint event of DataGridView/// <summary>        ///common methods for adding row headers used in the Rowpostpaint event of DataGridView/// </summary>        /// <param name= "DGV" >DataGridView Name</param>        /// <param name= "E" >Datagridviewrowpostpainteventargs Event name</param>         Public Static voidFillrowheaderindex ( ThisDataGridView DGV, Datagridviewrowpostpainteventargs e) {Rectangle Rectangle=NewRectangle (e.rowbounds.location.x, E.ROWBOUNDS.LOCATION.Y, D Gv. Rowheaderswidth-4, E.rowbounds.height); Textrenderer.drawtext (E.graphics, (E.rowindex+1). ToString (), DGV. Rowheadersdefaultcellstyle.font, Rectangle, DGV. Rowheadersdefaultcellstyle.forecolor, Textformatflags.verticalcenter|textformatflags.right); }        #endregion

name description
1 DrawText (IDeviceContext, String, Font, point, Color) draws the specified text at the specified location using the specified device context, font, and color.
2 DrawText (IDeviceContext, String, Font, Rectangle, Color) draws the specified text in the specified bounds, using the specified device context, font, and color.
3 DrawText (IDeviceContext, String, Font, point, color, color) draws the specified text at the specified location using the specified device context, font, color, and background color.
4 DrawText (IDeviceContext, String, Font, point, Color, TextFormatFlags) draws the specified text at the specified location using the specified device context, font, color, and formatting instructions.
5 DrawText (IDeviceContext, String, Font, Rectangle, color, color) draws the specified text in the specified bounds using the specified device context, font, color, and background color.
6 DrawText (IDeviceContext, String, Font, Rectangle, Color, TextFormatFlags) draws the specified text in the specified bounds using the specified device context, font, color, and format description.
7 DrawText (IDeviceContext, String, Font, point, color, color, textformatflags) draws the specified text at the specified location using the specified device context, font, color, background color, and formatting instructions
8 DrawText (IDeviceContext, String, Font, Rectangle, color, color, textformatflags) draws the specified text in the specified bounds using the specified device context, font, color, background color, and format description.

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.