本文整理汇总了C#中System.Windows.Forms.DataGridViewCellPaintingEventArgs.Paint方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewCellPaintingEventArgs.Paint方法的具体用法?C# DataGridViewCellPaintingEventArgs.Paint怎么用?C# DataGridViewCellPaintingEventArgs.Paint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridViewCellPaintingEventArgs
的用法示例。
在下文中一共展示了DataGridViewCellPaintingEventArgs.Paint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: dgvContours_CellPainting
private void dgvContours_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
e.Paint(e.ClipBounds, DataGridViewPaintParts.All);
e.Handled = true;
if (e.RowIndex < 0) return;
Template template = samples[e.RowIndex];
if (e.ColumnIndex == -1)
{
e.Graphics.DrawString(e.RowIndex.ToString(), Font, Brushes.Black, e.CellBounds.Location);
return;
}
if (e.ColumnIndex == 0)
{
var rect = new Rectangle(e.CellBounds.X, e.CellBounds.Y, (e.CellBounds.Width - 24)/2, e.CellBounds.Height);
rect.Inflate(-20, -20);
Rectangle boundRect = template.contour.SourceBoundingRect;
float k1 = 1f * rect.Width / boundRect.Width;
float k2 = 1f * rect.Height / boundRect.Height;
float k = Math.Min(k1, k2);
e.Graphics.DrawImage(bmp,
new Rectangle(rect.X, rect.Y, (int)(boundRect.Width * k), (int)(boundRect.Height * k)),
boundRect, GraphicsUnit.Pixel);
}
if (e.ColumnIndex == 0)
{
template.Draw(e.Graphics, e.CellBounds);
}
}
示例2: gvEmptyNetworkName_CellPainting
private void gvEmptyNetworkName_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex < 0)
return;
if (e.ColumnIndex == dcSelect.Index)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
e.Graphics.DrawImage(Resources.Select, e.CellBounds.Left + 3, e.CellBounds.Top + 3);
e.Handled = true;
}
}
示例3: AreasTree_CellPainting
private void AreasTree_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex < 0)
return;
if (e.ColumnIndex == dcSelectToReport.Index)
{
Image cellImage = Resources.print;
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
e.Graphics.DrawImage(cellImage, e.CellBounds.Left + 3, e.CellBounds.Top + 3);
e.Handled = true;
}
}
示例4: OnCellPainting
protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 1)
{
e.Paint(e.ClipBounds, DataGridViewPaintParts.Background | DataGridViewPaintParts.Border);
DrawGanttBar(e, e.RowIndex);
e.Handled = true;
}
else
{
base.OnCellPainting(e);
}
}
示例5: MembersDiffDataGridView_CellPainting
private void MembersDiffDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 5 || e.ColumnIndex == 11)
{
var rect = e.CellBounds;
using (var p = new Pen(Color.Black, 4))
{
e.Paint(e.CellBounds, e.PaintParts);
e.Graphics.DrawLine(p, new Point(rect.Right, rect.Top), new Point(rect.Right, rect.Bottom));
e.Handled = true;
}
}
}
示例6: dvgExtraccionesRefuerzos_CellPainting
private void dvgExtraccionesRefuerzos_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if ((e.ColumnIndex == 12 || e.ColumnIndex == 13 || e.ColumnIndex == 14) && e.RowIndex >= 0)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
string icon = string.Empty;
int paddingTop = 0;
int paddingLeft = 0;
switch (e.ColumnIndex)
{
case 12:
icon = @"\Resources\details_icon.ico";
paddingLeft = 3;
paddingTop = 3;
break;
case 13:
icon = @"\Resources\ico_edit.ico";
paddingLeft = 3;
paddingTop = 3;
break;
case 14:
icon = @"\Resources\delete_icon.ico";
paddingLeft = 5;
paddingTop = 4;
break;
}
Icon ico = new Icon(AppSettings.ApplicationPath + icon);
e.Graphics.DrawIcon(ico, e.CellBounds.Left + paddingLeft, e.CellBounds.Top + paddingTop);
e.Handled = true;
}
}
示例7: dataGridView1_CellPainting
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex < 0) return;
var dataRow = dataGridView1.Rows[e.RowIndex];
if (e.ColumnIndex == -1 && ((ListEntryViewModel) dataRow.DataBoundItem).IsDirty)
{
var imgSize = Resources.Pen.Size;
e.Paint(e.ClipBounds, DataGridViewPaintParts.All);
var cs = e.CellBounds.Size;
var center = e.CellBounds.Location + new Size(cs.Width/2, cs.Height/2);
var rect = Rectangle.Inflate(new Rectangle(center, Size.Empty), imgSize.Width/2, imgSize.Height/2);
e.Graphics.DrawImageUnscaled(Resources.Pen, rect);
e.Handled = true;
}
}
示例8: tblMOVIMIENTOS_CellPainting
private void tblMOVIMIENTOS_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
if (tblMOVIMIENTOS.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected == true)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.Border);
using (Pen p = new Pen(Color.Red, 1))
{
Rectangle rect = e.CellBounds;
rect.Width -= 2;
rect.Height -= 2;
e.Graphics.DrawRectangle(p, rect);
}
e.Handled = true;
}
}
}
示例9: dgLayers_CellPainting
private void dgLayers_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 0)
{
e.Graphics.FillRectangle(Brushes.White, e.CellBounds);
DataGridViewCell celula = dgLayers["columnVisible", e.RowIndex];
bool valor = Convert.ToBoolean(celula.Value);
if (valor)
e.Graphics.DrawImage(global::EditorMapa2D.Properties.Resources.ico_visible, e.CellBounds.X+1, e.CellBounds.Y+1, e.CellBounds.Width, e.CellBounds.Height);
e.Paint(e.CellBounds, ~DataGridViewPaintParts.ContentForeground & ~DataGridViewPaintParts.Background);
e.Handled = true;
}
}
示例10: dgvCards_CellPainting
/// <summary>
/// This is used to custom draw the version number cell
/// </summary>
/// <param name="sender">The sender of the event</param>
/// <param name="e">The event arguments</param>
private void dgvCards_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
Color foreColor;
string version;
if(e.RowIndex > -1 && e.ColumnIndex == 0)
{
version = ((SpecificationVersions)e.Value == SpecificationVersions.vCard21) ? "2.1" : "3.0";
e.Paint(e.CellBounds, e.PaintParts & ~DataGridViewPaintParts.ContentForeground);
// Based the foreground color on the selected state
if((e.State & DataGridViewElementStates.Selected) != 0)
foreColor = e.CellStyle.SelectionForeColor;
else
foreColor = e.CellStyle.ForeColor;
using(SolidBrush b = new SolidBrush(foreColor))
{
e.Graphics.DrawString(version, e.CellStyle.Font, b, e.CellBounds, sf);
}
e.Handled = true;
}
}
示例11: GridFactorReg_CellPainting
/// <summary>
/// عکس دیلیت
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GridFactorReg_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
try
{
if (e.ColumnIndex == 5 && e.RowIndex != -1)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
e.Graphics.DrawImage(Properties.Resources.del, e.CellBounds.Left + 5, e.CellBounds.Top);
e.Handled = true;
}
}
catch (DbUpdateException ex)
{
MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "فاکتور"), "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例12: OnCellPainting
protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == -1)
{
if (!(this._columnHeaderColor1 == Color.Transparent) && !(this._columnHeaderColor2 == Color.Transparent) &&
!this._columnHeaderColor1.IsEmpty && !this._columnHeaderColor2.IsEmpty)
{
DrawLinearGradient(e.CellBounds, e.Graphics, this._columnHeaderColor1, this._columnHeaderColor2);
e.Paint(e.ClipBounds, (DataGridViewPaintParts.All & ~DataGridViewPaintParts.Background));
e.Handled = true;
e.Graphics.DrawLine(new Pen(Color.FromArgb(179, 179, 179)),
new Point(e.CellBounds.X, e.CellBounds.Y + e.CellBounds.Height - 1),
new Point(e.CellBounds.Right, e.CellBounds.Y + e.CellBounds.Height - 1));
}
}
//画标题栏的分隔线
if (e.RowIndex == -1 && e.ColumnIndex > -1 && e.ColumnIndex < this.Columns.Count - 1)
{
Color Color1 = Color.FromArgb(0, 179, 179, 179);
Color Color2 = Color.FromArgb(179, 179, 179);
Color Color3 = Color.FromArgb(0, 179, 179, 179);
if (e.CellBounds.Width > 0 && e.CellBounds.Height > 0)
{
using (LinearGradientBrush brush = new LinearGradientBrush(
e.CellBounds, Color1, Color3, 90))
{
ColorBlend blend = new ColorBlend();
Color[] colors = new Color[3] { Color1, Color2, Color3 };
blend.Colors = colors;
blend.Positions = new float[] { 0f, .5f, 1f };
brush.InterpolationColors = blend;
using (Pen pen = new Pen(brush))
{
e.Graphics.DrawLine(pen, e.CellBounds.X + e.CellBounds.Width - 2, e.CellBounds.Y - 2,
e.CellBounds.X + e.CellBounds.Width - 2, e.CellBounds.Y + e.CellBounds.Height - 2);
}
}
}
}
if (e.RowIndex == -1 && this.isShowArrow && this.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
{
if (this.oldSelectedColumn != null && this.oldSelectedColumn.Index > -1)
{
//绘制排序的箭头
if (e.ColumnIndex == this.oldSelectedColumn.Index)
{
bool isUpArrow = false;
if (this.sortOrder == SortOrder.Ascending)
{
isUpArrow = true;
}
Rectangle rect = new Rectangle();
rect.X = e.CellBounds.X + e.CellBounds.Width - 14;
rect.Y = e.CellBounds.Y + 13;
rect.Width = 8;
rect.Height = 6;
using (GraphicsPath path = GetArrowPath(rect, isUpArrow))
{
using (Brush brush = new SolidBrush(Color.Silver))
{
e.Graphics.FillPath(brush, path);
}
using (Pen pen = new Pen(Color.Silver))
{
e.Graphics.DrawPath(pen, path);
}
}
}
}
}
base.OnCellPainting(e);
}
示例13: dGVPVCession_CellPainting
private void dGVPVCession_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == -1 || e.RowIndex == -1)
return;
if (dGVPVCession.Columns[e.ColumnIndex].Name == "ColumnImprimer")
{
if (e.RowIndex != dGVPVCession.RowCount - 1)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
int intTop = (e.CellBounds.Height - 16) / 2 + e.CellBounds.Top;
int intLeft = (e.CellBounds.Width - 16) / 2 + e.CellBounds.Left;
try
{
e.Graphics.DrawImage(System.Drawing.Image.FromFile("imprimer.jpeg"), intLeft, intTop);
}
catch (Exception)
{ }
e.Handled = true;
}
}
else
if (dGVPVCession.Columns[e.ColumnIndex].Name == "ColumnModifier")
{
if (e.RowIndex != dGVPVCession.RowCount - 1)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
int intTop = (e.CellBounds.Height - 16) / 2 + e.CellBounds.Top;
int intLeft = (e.CellBounds.Width - 10) / 2 + e.CellBounds.Left;
try
{
e.Graphics.DrawImage(System.Drawing.Image.FromFile("modifier.gif"), intLeft, intTop);
}
catch (Exception)
{ }
e.Handled = true;
}
else
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
int intTop = (e.CellBounds.Height - 16) / 2 + e.CellBounds.Top;
int intLeft = (e.CellBounds.Width - 16) / 2 + e.CellBounds.Left;
try
{
e.Graphics.DrawImage(System.Drawing.Image.FromFile("images.jpeg"), intLeft, intTop);
}
catch (Exception)
{ }
e.Handled = true;
}
}
}
示例14: QuestView_CellPainting
private void QuestView_CellPainting( object sender, DataGridViewCellPaintingEventArgs e )
{
if ( e.ColumnIndex != QuestView_Progress.Index ||
e.RowIndex < 0 ||
( e.PaintParts & DataGridViewPaintParts.Background ) == 0 )
return;
using ( var bback = new SolidBrush( e.CellStyle.BackColor ) ) {
Color col;
double rate = QuestView.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag as double? ?? 0.0;
if ( rate < 0.5 ) {
col = Color.FromArgb( 0xFF, 0x88, 0x00 );
} else if ( rate < 0.8 ) {
col = Color.FromArgb( 0x00, 0xCC, 0x00 );
} else if ( rate < 1.0 ) {
col = Color.FromArgb( 0x00, 0x88, 0x00 );
} else {
col = Color.FromArgb( 0x00, 0x88, 0xFF );
}
using ( var bgauge = new SolidBrush( col ) ) {
const int thickness = 4;
e.Graphics.FillRectangle( bback, e.CellBounds );
e.Graphics.FillRectangle( bgauge, new Rectangle( e.CellBounds.X, e.CellBounds.Bottom - thickness, (int)( e.CellBounds.Width * rate ), thickness ) );
}
}
e.Paint( e.ClipBounds, e.PaintParts & ~DataGridViewPaintParts.Background );
e.Handled = true;
}
示例15: grdConnectionProperties_CellPainting
private void grdConnectionProperties_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
DataGridViewCell cell = grdConnectionProperties.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (cell != null && IsPasswordCell(cell) && cell.Value != null)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentForeground);
Graphics g = e.Graphics;
g.DrawString(new string('*', cell.Value.ToString().Length), this.Font, new SolidBrush(Color.Black), e.CellBounds);
e.Handled = true;
}
}
}