本文整理汇总了C#中System.Windows.Forms.DataGridViewRowPostPaintEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewRowPostPaintEventArgs类的具体用法?C# DataGridViewRowPostPaintEventArgs怎么用?C# DataGridViewRowPostPaintEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewRowPostPaintEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewRowPostPaintEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRowPostPaint
/// <summary>
/// draw the row number on the header cell, auto adjust the column width
/// to fit the row number
/// </summary>
/// <param name="e"></param>
protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
{
base.OnRowPostPaint(e);
// get the row number in leading zero format,
// where the width of the number = the width of the maximum number
int RowNumWidth = this.RowCount.ToString().Length;
StringBuilder RowNumber = new StringBuilder(RowNumWidth);
RowNumber.Append(e.RowIndex + 1);
while (RowNumber.Length < RowNumWidth)
RowNumber.Insert(0, "0");
// get the size of the row number string
SizeF Sz = e.Graphics.MeasureString(RowNumber.ToString(), this.Font);
// adjust the width of the column that contains the row header cells
if (this.RowHeadersWidth < (int)(Sz.Width + 20))
this.RowHeadersWidth = (int)(Sz.Width + 20);
// draw the row number
e.Graphics.DrawString(
RowNumber.ToString(),
this.Font,
SystemBrushes.ControlText,
e.RowBounds.Location.X + 15,
e.RowBounds.Location.Y + ((e.RowBounds.Height - Sz.Height) / 2));
}
示例2: dataGridView1_RowPostPaint
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
DataGridView dgv = sender as DataGridView;
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);
}
示例3: dataGridView1_RowPostPaint
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
int rownum = (e.RowIndex + 1);
Rectangle rct = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y + 4, dataGridView1.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, rownum.ToString(), dataGridView1.RowHeadersDefaultCellStyle.Font,
rct, dataGridView1.RowHeadersDefaultCellStyle.ForeColor, System.Drawing.Color.Transparent, TextFormatFlags.HorizontalCenter);
}
示例4: grdDM_ChuyenDoiMucHuong_RowPostPaint
private void grdDM_ChuyenDoiMucHuong_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(grdDM_ChuyenDoiMucHuong.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 2, e.RowBounds.Location.Y + 5);
}
}
示例5: dgvProduct_RowPostPaint
private void dgvProduct_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(dgvProduct.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 4);
}
}
示例6: OnRowPostPaint
/// <summary>
/// 增加datagridview前面的序列号
/// </summary>
/// <param name="e"></param>
protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
{
System.Drawing.Rectangle rectangle =
new System.Drawing.Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, Convert.ToInt32(e.RowIndex + 1).ToString(), this.RowHeadersDefaultCellStyle.Font, rectangle, this.
RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
base.OnRowPostPaint(e);
}
示例7: OnRowPostPaint
protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
{
base.OnRowPostPaint(e);
using (SolidBrush b = new SolidBrush(RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 4);
}
}
示例8: DataGridView_RowPostPaint
private void DataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
// Paint the row number on the row header.
// The using statement automatically disposes the brush.
using (SolidBrush brush = new SolidBrush(this.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, brush, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
}
示例9: dwRowPostPaint
/// <summary>
/// DataGridView绘制行号
/// </summary>
/// <param name="dw">DataGridView</param>
/// <param name="e">事件e</param>
public void dwRowPostPaint(DataGridView dw, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dw.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
dw.RowHeadersDefaultCellStyle.Font,
rectangle, dw.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
示例10: DataGridViewEx_RowPostPaint
//绘制行号
private void DataGridViewEx_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
if (this.showRowHeaderNumbers)
{
string s = (e.RowIndex + 1).ToString();
Brush black = Brushes.Black;
e.Graphics.DrawString(s, base.DefaultCellStyle.Font, black, (float) ((e.RowBounds.Location.X + (base.RowHeadersWidth / 2)) - 4), (float) (e.RowBounds.Location.Y + 4));
}
}
开发者ID:lc1915,项目名称:Project-of-Information-Systems-Development-Methods-and-Tools,代码行数:10,代码来源:newDGV.cs
示例11: dbgrid_RowPostPaint
/// <summary>
/// 设置表格行标号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void dbgrid_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
DataGridView grid = sender as DataGridView;
if (null == grid) return;
using (SolidBrush b = new SolidBrush(grid.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(CultureInfo.CurrentCulture),
grid.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
}
示例12: dataGridView1_RowPostPaint
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
if(e.RowIndex>-1)
{
DataGridViewCellCollection cells=this.dataGridView1.Rows[e.RowIndex].Cells;
if(cells[2].Value.ToString()!=cells[3].Value.ToString())
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
}
}
}
示例13: OnRowPostPaint
protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
{
string strRowNumber = (e.RowIndex + 1).ToString();
while (strRowNumber.Length < this.RowCount.ToString().Length) strRowNumber = "0" + strRowNumber;
SizeF size = e.Graphics.MeasureString(strRowNumber, this.Font);
if (this.RowHeadersWidth < (int)(size.Width + 20)) this.RowHeadersWidth = (int)(size.Width + 20);
Brush b = SystemBrushes.ControlText;
e.Graphics.DrawString(strRowNumber, this.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2));
base.OnRowPostPaint(e);
}
示例14: dataGridView1_RowPostPaint
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
var strRowNumber = (e.RowIndex + 1).ToString();
var size = e.Graphics.MeasureString(strRowNumber, Font);
if (dataGridView1.RowHeadersWidth < Convert.ToInt32((size.Width + 20)))
{
dataGridView1.RowHeadersWidth = Convert.ToInt32((size.Width + 20));
}
var b = SystemBrushes.ControlText;
e.Graphics.DrawString(strRowNumber, Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2));
}
示例15: OnRowPostPaint
/// <summary>
/// This adds a ROW number to the grid, so you can see how many records
/// are shown in the data set.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnRowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
var grid = sender as DataGridView;
var rowIdx = (e.RowIndex + 1).ToString();
var centerFormat = new StringFormat()
{
// right alignment might actually make more sense for numbers
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
var headerBounds = new Rectangle(e.RowBounds.Left, e.RowBounds.Top, grid.RowHeadersWidth, e.RowBounds.Height);
e.Graphics.DrawString(rowIdx, this.Font, SystemBrushes.ControlText, headerBounds, centerFormat);
}