Esempio n. 1
0
        /// <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));
        }
Esempio n. 2
0
 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);
 }
 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);
 }
Esempio n. 4
0
 public static void enumerarFilasDatagridview(DataGridView DataGridView1, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
 {
     try
     {
         //Captura el numero de filas del datagridview
         string RowsNumber = (e.RowIndex + 1).ToString();
         while (RowsNumber.Length < DataGridView1.RowCount.ToString().Length)
         {
             RowsNumber = "0" + RowsNumber;
         }
         System.Drawing.SizeF size = e.Graphics.MeasureString(RowsNumber, DataGridView1.Font);
         if (DataGridView1.RowHeadersWidth < Convert.ToInt32(size.Width + 20))
         {
             DataGridView1.RowHeadersWidth = Convert.ToInt32(size.Width + 20);
         }
         else
         {
             DataGridView1.RowHeadersWidth = Convert.ToInt32(size.Width + 20);
         }
         System.Drawing.Brush ob = System.Drawing.SystemBrushes.ControlText;
         e.Graphics.DrawString(RowsNumber, DataGridView1.Font, ob, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "CS", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 5
0
 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);
     }
 }
 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);
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 8
0
 /// <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);
 }
Esempio n. 9
0
 static void UIMessage_RowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
 {
     System.Windows.Forms.DataGridView grd = ((System.Windows.Forms.DataGridView)sender);
     using (System.Drawing.SolidBrush b = new System.Drawing.SolidBrush(grd.RowHeadersDefaultCellStyle.ForeColor))
     {
         e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 8, e.RowBounds.Location.Y + 4);
     }
 }
Esempio n. 10
0
 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);
     }
 }
Esempio n. 11
0
        /// <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);
        }
 //绘制行号
 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));
     }
 }
Esempio n. 13
0
 /// <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);
     }
 }
Esempio n. 14
0
 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));
 }
Esempio n. 15
0
 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;
         }
     }
 }
        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);
        }
        private void DataGridView1_RowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
        {
            string strRowNumber = (e.RowIndex + 1).ToString();
            SizeF  size         = e.Graphics.MeasureString(strRowNumber, this.Font);

            if (DataGridView1.RowHeadersWidth < Convert.ToInt32((size.Width + 20)))
            {
                DataGridView1.RowHeadersWidth = Convert.ToInt32((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));
        }
Esempio n. 18
0
        private void DgvDepotsRowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
        {
            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X,
                                                                              e.RowBounds.Location.Y,
                                                                              this.View.DgvDepots.RowHeadersWidth - 4,
                                                                              e.RowBounds.Height);

            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                  this.View.DgvDepots.RowHeadersDefaultCellStyle.Font,
                                  rectangle,
                                  this.View.DgvDepots.RowHeadersDefaultCellStyle.ForeColor,
                                  TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
        }
Esempio n. 19
0
        /// <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);
        }
Esempio n. 20
0
        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);
            }
        }
Esempio n. 21
0
 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
            );
     }
 }
Esempio n. 22
0
        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;
                }
            }
        }
Esempio n. 23
0
 /// <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, "操作失败");
     }
 }
Esempio n. 24
0
 /// <summary>重新画行头
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void DataGridEx_RowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
 {
     try
     {
         Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y,
                                             this.RowHeadersWidth - 4, e.RowBounds.Height);
         TextRenderer.DrawText(e.Graphics, ((e.RowIndex) + 1).ToString(),
                               this.RowHeadersDefaultCellStyle.Font,
                               rectangle, this.RowHeadersDefaultCellStyle.ForeColor,
                               TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        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);
        }
Esempio n. 26
0
        void HandleRowPostPaint(object sender, swf.DataGridViewRowPostPaintEventArgs e)
        {
            if (handledAutoSize)
            {
                return;
            }

            handledAutoSize = true;
            int colNum = 0;

            foreach (var col in Widget.Columns)
            {
                var colHandler = col.Handler as GridColumnHandler;
                if (col.AutoSize)
                {
                    Control.AutoResizeColumn(colNum, colHandler.Control.InheritedAutoSizeMode);
                    var width = col.Width;
                    colHandler.Control.AutoSizeMode = swf.DataGridViewAutoSizeColumnMode.None;
                    col.Width = width;
                }
                colNum++;
            }
        }
Esempio n. 27
0
 private void DataGridViewRowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 {
     //======================================================
     //标识行号
     try
     {
         DataGridView dgv = sender as DataGridView;
         Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
                                             Convert.ToInt32(e.RowBounds.Location.Y + (e.RowBounds.Height - dgv.RowHeadersDefaultCellStyle.Font.Size) / 2),
                                             dgv.RowHeadersWidth - 4,
                                             e.RowBounds.Height);
         TextRenderer.DrawText(e.Graphics,
                              (e.RowIndex + 1).ToString(),
                              dgv.RowHeadersDefaultCellStyle.Font,
                              rectangle,
                              dgv.RowHeadersDefaultCellStyle.ForeColor,
                               TextFormatFlags.Right);
     }
     catch (Exception ex)
     {
         Console.Write("RowPostPaint:" + ex.Message);
     }
 }
Esempio n. 28
0
        private void DataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            //using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor))
            //{
            //    e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 4);
            //}

            var grid = sender as DataGridView;
            var rowIdx = (e.RowIndex + 1).ToString();

            var rightformat = new StringFormat()
            {
                // right alignment might actually make more sense for numbers
                Alignment = StringAlignment.Near,
                LineAlignment = StringAlignment.Near
            };

            var headerBounds = new Rectangle(e.RowBounds.Right + e.RowBounds.Left - grid.RowHeadersWidth, e.RowBounds.Top, grid.RowHeadersWidth, e.RowBounds.Height);
            e.Graphics.DrawString(rowIdx, this.Font, SystemBrushes.ControlText, headerBounds, rightformat);

            //var headerBounds As Rectangle = New Rectangle(e.RowBounds.Left + e.RowBounds.Right - grid.RowHeadersWidth, e.RowBounds.Top, grid.RowHeadersWidth, e.RowBounds.Height)
            //e.Graphics.DrawString(rowIdx, this.Font, SystemBrushes.ControlText, headerBounds, centerFormat);
        }
Esempio n. 29
0
        /// <summary>Overrides the RowPostPaint event to draw on row numbers</summary>
        protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
        {
            string strRowNumber = (e.RowIndex + 1).ToString();

            //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);
        }
		/// <summary>
		/// Invokes resizing of a column. We do this because the DataGridView autosize functionality
		/// doesn't seem to work as advertised
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
		{
			DataGridViewHelper.ResizeColumn(dataGridView1, 0);
		}
Esempio n. 31
0
 private void dataGridView_day_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 {
     RowHeaderPaint(e);
 }
Esempio n. 32
0
 private void RowHeaderPaint(DataGridViewRowPostPaintEventArgs e)
 {
     switch (e.RowIndex)
     {
         case 0:
             e.Graphics.DrawString("应收", new Font("宋体", 9), Brushes.Black, e.RowBounds.Left + 15, e.RowBounds.Top + 5);
             break;
         case 1:
             e.Graphics.DrawString("支出", new Font("宋体", 9), Brushes.Black, e.RowBounds.Left + 15, e.RowBounds.Top + 5);
             break;
         case 2:
             e.Graphics.DrawString("调整", new Font("宋体", 9), Brushes.Black, e.RowBounds.Left + 15, e.RowBounds.Top + 5);
             break;
         case 3:
             e.Graphics.DrawString("余额", new Font("宋体", 9), Brushes.Black, e.RowBounds.Left + 15, e.RowBounds.Top + 5);
             break;
         case 4:
             e.Graphics.DrawString("备注", new Font("宋体", 9), Brushes.Black, e.RowBounds.Left + 15, e.RowBounds.Top + 5);
             break;
         default:
             break;
     }
 }
Esempio n. 33
0
        /// <summary>
        /// Update row number display for those only in view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            var grid = sender as DataGridView;
            var rowIdx = grid.Rows[e.RowIndex].Cells[0].Value.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, new SolidBrush(this.ForeColor), headerBounds, centerFormat);

            //
        }
Esempio n. 34
0
 void GridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 {
     this.dataGridView1.Rows[e.RowIndex].Cells[0].Value
      = (e.RowIndex + 1).ToString();
 }
Esempio n. 35
0
 private void dgvLogData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         try
         {
             string str = "";
             if (this.dgvLogData.Rows[e.RowIndex].Cells["OrderType"].Value != DBNull.Value)
             {
                 str = this.dgvLogData.Rows[e.RowIndex].Cells["OrderType"].Value.ToString();
             }
             if ((str == "报警") || (str == "信息"))
             {
                 this.img = Resources.mAlarm;
             }
             else if (str == "警告")
             {
                 this.img = Resources.mNormal;
             }
             else
             {
                 this.img = Resources.mInfo;
             }
             Rectangle rect = new Rectangle((e.RowBounds.X + 3) - this.iScroll, e.RowBounds.Y + 1, 16, 16);
             e.Graphics.DrawImage(this.img, rect);
         }
         catch
         {
         }
     }
 }
Esempio n. 36
0
 private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 {
     DataGridViewService.VisibleRowOrder(dataGridView1, e);
 }