標籤:des winform datagridview c style class
#region 寫行號事件 //在DataGridView控制項上選擇RowPostPaint事件 private void dgvJointList_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { ((DataGridView)sender).fillRowHeaderIndex(e); } #endregion
#region DataGridView的RowPostPaint事件中使用的添加列名的公用方法 /// <summary> /// DataGridView的RowPostPaint事件中使用的添加列名的公用方法 /// </summary> /// <param name="dgv">DataGridView名</param> /// <param name="e">DataGridViewRowPostPaintEventArgs事件名</param> public static void fillRowHeaderIndex(this DataGridView dgv, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new Rectangle ( e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.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
|
名稱 |
說明 |
1 |
DrawText(IDeviceContext, String, Font, Point, Color) |
使用指定的裝置上下文、字型和顏色在指定位置繪製指定文本。 |
2 |
DrawText(IDeviceContext, String, Font, Rectangle, Color) |
使用指定的裝置上下文、字型和顏色在指定界限中繪製指定文本。 |
3 |
DrawText(IDeviceContext, String, Font, Point, Color, Color) |
使用指定的裝置上下文、字型、顏色和背景色在指定位置繪製指定文本。 |
4 |
DrawText(IDeviceContext, String, Font, Point, Color, TextFormatFlags) |
使用指定的裝置上下文、字型、顏色和格式說明在指定位置繪製指定文本。 |
5 |
DrawText(IDeviceContext, String, Font, Rectangle, Color, Color) |
使用指定的裝置上下文、字型、顏色和背景色在指定界限中繪製指定文本。 |
6 |
DrawText(IDeviceContext, String, Font, Rectangle, Color, TextFormatFlags) |
使用指定的裝置上下文、字型、顏色和格式說明在指定界限中繪製指定文本。 |
7 |
DrawText(IDeviceContext, String, Font, Point, Color, Color, TextFormatFlags) |
使用指定的裝置上下文、字型、顏色、背景色和格式說明在指定位置繪製指定文本 |
8 |
DrawText(IDeviceContext, String, Font, Rectangle, Color, Color, TextFormatFlags) |
使用指定的裝置上下文、字型、顏色、背景色和格式說明在指定界限中繪製指定文本。 |