• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.DataGridViewRowPostPaintEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Forms.DataGridViewRowPostPaintEventArgs的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewRowPostPaintEventArgs类的具体用法?C# DataGridViewRowPostPaintEventArgs怎么用?C# DataGridViewRowPostPaintEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataGridViewRowPostPaintEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewRowPostPaintEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: dgvUserDetails_RowPostPaint

        private void dgvUserDetails_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            using (SolidBrush b = new SolidBrush(MainOutputData.RowHeadersDefaultCellStyle.ForeColor))
            {
                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, (sender as DataGridView).RowHeadersWidth, e.RowBounds.Height);
                e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, headerBounds, centerFormat);
            }
        }
开发者ID:ElenaAgeeva,项目名称:Stock,代码行数:15,代码来源:Form1.cs


示例17: dataGridViewUsers_RowPostPaint

        private void dataGridViewUsers_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            List<string> UserIds = (new DBUtil()).GetOneFiledData("T_UserRelation", "ParentPId");

            foreach (DataGridViewRow dr in this.dataGridViewUsers.Rows)
            {
                string userId = "";
                if (dr.Cells["用户编码"].Value != null)
                    userId = dr.Cells["用户编码"].Value.ToString().Trim();
                if (UserIds.Contains(userId))
                {
                    dr.HeaderCell.Value = "*";
                    dr.HeaderCell.Style.ForeColor = Color.Red;
                }
            }
        }
开发者ID:TGHGH,项目名称:Warehouse-2,代码行数:16,代码来源:UsersForm.cs


示例18: dgvGame_RowPostPaint

 private void dgvGame_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 {
     var dgv = (DataGridView)sender;
     if (dgv.RowHeadersVisible)
     {
         Rectangle rect = new Rectangle(e.RowBounds.Left, e.RowBounds.Top,
                                        dgv.RowHeadersWidth, e.RowBounds.Height);
         rect.Inflate(-2, -2);
         TextRenderer.DrawText(e.Graphics,
            (e.RowIndex + 1).ToString(),
            e.InheritedRowStyle.Font,
            rect, e.InheritedRowStyle.ForeColor,
            TextFormatFlags.Right | TextFormatFlags.VerticalCenter
            );
     }
 }
开发者ID:hanxinlei2002,项目名称:LotteryApp,代码行数:16,代码来源:frmHistory.cs


示例19: DgvRowPostPaint

 /// <summary>
 /// 给DataGridView添加行号
 /// </summary>
 /// <param name="dgv"></param>
 /// <param name="e"></param>
 public static void DgvRowPostPaint(DataGridView dgv, DataGridViewRowPostPaintEventArgs e)
 {
     try
     {
         //添加行号 
         SolidBrush v_SolidBrush = new SolidBrush(dgv.RowHeadersDefaultCellStyle.ForeColor);
         int v_LineNo = 0;
         v_LineNo = e.RowIndex + 1;
         string v_Line = v_LineNo.ToString();
         e.Graphics.DrawString(v_Line, e.InheritedRowStyle.Font, v_SolidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5);
     }
     catch (Exception ex)
     {
         MessageBox.Show("添加行号时发生错误,错误信息:" + ex.Message, "操作失败");
     }
 }
开发者ID:lev2048,项目名称:C_Sharp,代码行数:21,代码来源:DataGridViewStyle.cs


示例20: OnRowPostPaint

        protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
        {
            // this method overrides the DataGridView's RowPostPaint event
            // in order to automatically draw numbers on the row header cells
            // and to automatically adjust the width of the column containing
            // the row header cells so that it can accommodate the new row
            // numbers.

            // store a string representation of the row number in 'strRowNumber'
            string strRowNumber = (e.RowIndex + 1).ToString();

            // prepend leading zeros to the string if necessary to improve
            // appearance. For example, if there are ten rows in the grid,
            // row seven will be numbered as "07" instead of "7". Similarly, if
            // there are 100 rows in the grid, row seven will be numbered as "007".
            while (strRowNumber.Length < this.RowCount.ToString().Length)
            {
                strRowNumber = "0" + strRowNumber;
            }

            // determine the display size of the row number string using
            // the DataGridView's current font.
            SizeF size = e.Graphics.MeasureString(strRowNumber, this.Font);

            // adjust the width of the column that contains the row header cells
            // if necessary
            if (this.RowHeadersWidth < (int)(size.Width + 20))
            {
                this.RowHeadersWidth = (int)(size.Width + 20);
            }

            // this brush will be used to draw the row number string on the
            // row header cell using the system's current ControlText color
            Brush b = SystemBrushes.ControlText;

            // draw the row number string on the current row header cell using
            // the brush defined above and the DataGridView's default font
            e.Graphics.DrawString(
                strRowNumber,
                this.Font,
                b,
                e.RowBounds.Location.X + 15,
                e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2));

            // call the base object's OnRowPostPaint method
            base.OnRowPostPaint(e);
        }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:47,代码来源:DataGridViewNumbered.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.DataGridViewRowPrePaintEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Forms.DataGridViewRowEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap