當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。