⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datagridcheckboxcolumn.cs

📁 一个用vs2003编写的客户工资管理系统客户端程序/一个用vs2003编写的客户工资管理系统客户端程序
💻 CS
字号:
using System;
using System.Drawing;
using System.Windows.Forms;

namespace GzglClient.ColumnStyles
{
	/// <summary>
	/// DataGridCheckBoxColumn 的摘要说明。
	/// </summary>
	public class DataGridCheckBoxColumn : System.Windows.Forms.DataGridTextBoxColumn
	{
		public DataGridCheckBoxColumn(string headerText, string mappingName, int width)
		{
			base.HeaderText = headerText;
			base.MappingName = mappingName;
			base.Width = width;
		}

		protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool isReadOnly, string instantText, bool cellIsVisible)
		{
			// Do Nothing
		}

		protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
		{
			int progressVal = (int) GetColumnValueAtRow(source, rowNum);
			float percentage = ((float) progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.

			// if the current row is this row, draw the selection back color
			if (this.DataGridTableStyle.DataGrid.CurrentRowIndex == rowNum)
				g.FillRectangle(new SolidBrush(this.DataGridTableStyle.SelectionBackColor), bounds);
			else
				g.FillRectangle(backBrush, bounds);

			if (percentage > 0.0)
			{
				// Draw the progress bar and the text
				g.FillRectangle(new SolidBrush(Color.FromArgb(163, 189, 242)), bounds.X + 2, bounds.Y + 2, Convert.ToInt32((percentage * bounds.Width - 4)), bounds.Height - 4);
				g.DrawString(progressVal.ToString() + "%", this.DataGridTableStyle.DataGrid.Font, foreBrush, bounds.X + 6, bounds.Y + 2);
			}
			else
			{
				// draw the text
				if (this.DataGridTableStyle.DataGrid.CurrentRowIndex == rowNum)
					g.DrawString(progressVal.ToString() + "%", this.DataGridTableStyle.DataGrid.Font, new SolidBrush(this.DataGridTableStyle.SelectionForeColor), bounds.X + 6, bounds.Y + 2);
				else
					g.DrawString(progressVal.ToString() + "%", this.DataGridTableStyle.DataGrid.Font, foreBrush, bounds.X + 6, bounds.Y + 2);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -