当前位置: 首页>>代码示例>>C#>>正文


C# Forms.DataGridViewRowPostPaintEventArgs类代码示例

本文整理汇总了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));
        }
开发者ID:pirzada,项目名称:sinapse,代码行数:32,代码来源:IndexDataGridView.cs

示例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);
 }
开发者ID:dishiyicijinqiu,项目名称:FengSharp,代码行数:7,代码来源:DataGridView_ShowLine.cs

示例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);
 }
开发者ID:JiangJunGG,项目名称:SyAutoH,代码行数:7,代码来源:Form1.cs

示例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);
     }
 }
开发者ID:itcthienkhiem,项目名称:DienLucHocMonCT,代码行数:7,代码来源:frmDanhMucChuyenDoiMucHuong.cs

示例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);
     }
 }
开发者ID:nguyenxuantung,项目名称:TEST,代码行数:7,代码来源:frmProduct_update.cs

示例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);
 }
开发者ID:treejames,项目名称:HYMES,代码行数:12,代码来源:DataGridViewExt.cs

示例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);
     }
 }
开发者ID:Winsor,项目名称:ITInfra,代码行数:8,代码来源:DataGridViewCustomedMS.cs

示例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);
     }
 }
开发者ID:labeuze,项目名称:source,代码行数:9,代码来源:DataGridViewControl.cs

示例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);
        }
开发者ID:DevelopingTeam,项目名称:Common,代码行数:14,代码来源:txtImport.cs

示例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);
     }
 }
开发者ID:BillyWu,项目名称:Granitypark,代码行数:15,代码来源:FrmDepositAll_del.cs

示例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;
         }
     }
 }
开发者ID:romanu6891,项目名称:fivemen,代码行数:11,代码来源:UserExamDetail.cs

示例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);
        }
开发者ID:sunnysunhuajun,项目名称:BuilderCode,代码行数:11,代码来源:SerialNumberDataGridView.cs

示例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));
 }
开发者ID:epiczeth,项目名称:Ported,代码行数:11,代码来源:frmStockRecord1.cs

示例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);
        }
开发者ID:jiangtang-test,项目名称:SasHarness,代码行数:21,代码来源:DataViewerForm.cs


注:本文中的System.Windows.Forms.DataGridViewRowPostPaintEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。