当前位置: 首页>>代码示例>>C#>>正文


C# DataGridViewCellPaintingEventArgs.Paint方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Lapa-Alya,项目名称:SearchOfHouseNumbers,代码行数:34,代码来源:ShowContoursForm.cs

示例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;
     }
 }
开发者ID:Winsor,项目名称:ITInfra,代码行数:11,代码来源:EmptyNetworkName.cs

示例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;
     }
 }
开发者ID:Winsor,项目名称:ITInfra,代码行数:12,代码来源:AreaDetailSelection.cs

示例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);
     }
 }
开发者ID:japj,项目名称:bidshelper,代码行数:13,代码来源:DtsGanttGrid.cs

示例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;
                }
            }
        }
开发者ID:osbeorn,项目名称:fireDeptFeesTool,代码行数:14,代码来源:ImportMembersDiffForm.cs

示例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;
            }
        }
开发者ID:pragmasolutions,项目名称:Maxikioscos,代码行数:33,代码来源:CierreCajaActual.cs

示例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;
            }
        }
开发者ID:juanii,项目名称:NEbml,代码行数:16,代码来源:EditMkvAttributesForm.cs

示例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;
         }
     }
 }
开发者ID:Alex-Palacios,项目名称:DDSIC,代码行数:18,代码来源:PartidaDiariaForm.cs

示例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;
            }
        }
开发者ID:farlei,项目名称:libEGL,代码行数:17,代码来源:frmMain.cs

示例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;
            }
        }
开发者ID:modulexcite,项目名称:PDI,代码行数:30,代码来源:VCardBrowserForm.cs

示例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);
     }
 }
开发者ID:NavidDorfeshan,项目名称:WinFormapp_EsfahanGhos,代码行数:25,代码来源:Form_RegFactorListItem.cs

示例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);
        }
开发者ID:JackWangCUMT,项目名称:winform-control-lib,代码行数:82,代码来源:WSNDataGridView.cs

示例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;
                    }
                }
        }
开发者ID:kimboox44,项目名称:inventaire,代码行数:52,代码来源:PVsCessions.cs

示例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;
        }
开发者ID:hirsaeki,项目名称:ElectronicObserver,代码行数:38,代码来源:FormQuest.cs

示例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;
         }
     }
 }
开发者ID:jumpinjackie,项目名称:fdotoolbox,代码行数:14,代码来源:FdoCreateDataStoreCtl.cs


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