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


C# DataGridViewPaintParts.HasFlag方法代码示例

本文整理汇总了C#中DataGridViewPaintParts.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewPaintParts.HasFlag方法的具体用法?C# DataGridViewPaintParts.HasFlag怎么用?C# DataGridViewPaintParts.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataGridViewPaintParts的用法示例。


在下文中一共展示了DataGridViewPaintParts.HasFlag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AfterPaintContent

        /// <summary>
        /// Paints common elements in front of the cell content.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected void AfterPaintContent(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.ErrorIcon)) {
                base.PaintErrorIcon(graphics, clipBounds, cellBounds, GetErrorText(rowIndex));
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Border)) {
                base.PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Focus) && (DataGridView.CurrentCell == this)) {
                Rectangle focusBounds = cellBounds;
                focusBounds.Width--;
                focusBounds.Height--;
                ControlPaint.DrawFocusRectangle(graphics, focusBounds);
            }
        }
开发者ID:zwolsman,项目名称:proftaak,代码行数:27,代码来源:DropDownColumnBase.cs

示例2: BeforePaintContent

        /// <summary>
        /// Paints common elements behind the cell content.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cellBounds"></param>
        /// <param name="cellState"></param>
        /// <param name="cellStyle"></param>
        /// <param name="paintParts"></param>
        protected void BeforePaintContent(Graphics graphics, Rectangle cellBounds, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.Background)) {
                using (Brush brush = new SolidBrush(cellStyle.BackColor)) {
                    graphics.FillRectangle(brush, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.SelectionBackground) && cellState.HasFlag(DataGridViewElementStates.Selected)) {
                using (Brush brush = new SolidBrush(cellStyle.SelectionBackColor)) {
                    graphics.FillRectangle(brush, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentBackground)) {
                ComboBoxState state = ComboBoxState.Normal;
                ButtonState legacyState = ButtonState.Normal;

                if ((DataGridView.Site == null) || !DataGridView.Site.DesignMode) {
                    if (cellState.HasFlag(DataGridViewElementStates.ReadOnly)) {
                        state = ComboBoxState.Disabled;
                        legacyState = ButtonState.Inactive;
                    }
                    else if (cellBounds.Contains(DataGridView.PointToClient(DataGridView.MousePosition))) {
                        if (DataGridView.MouseButtons.HasFlag(MouseButtons.Left)) {
                            state = ComboBoxState.Pressed;
                            legacyState = ButtonState.Pushed;
                        }
                        else {
                            state = ComboBoxState.Hot;
                        }
                    }
                }

                Rectangle comboBounds = cellBounds;
                comboBounds.Width--;

                if (((DropDownColumnBase)OwningColumn).BufferedPaintingSupported) {
                    GroupedComboBox.DrawComboBox(graphics, comboBounds, state);
                }
                else {
                    DropDownControlBase.DrawLegacyComboBox(graphics, comboBounds, DropDownControlBase.GetComboButtonBounds(comboBounds), cellStyle.BackColor, legacyState);
                }
            }
        }
开发者ID:zwolsman,项目名称:proftaak,代码行数:53,代码来源:DropDownColumnBase.cs

示例3: Paint

        /// <summary>
        /// Paints the cell.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground)) {
                Rectangle contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags = TextFormatFlags.NoPrefix | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.PreserveGraphicsClipping;
                TextRenderer.DrawText(graphics, Convert.ToString(formattedValue), cellStyle.Font, contentBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }
开发者ID:zwolsman,项目名称:proftaak,代码行数:29,代码来源:GroupedComboBoxColumn.cs

示例4: Paint

        /// <summary>
        /// Paints the cell.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground)) {
                ComboTreeBoxColumn column = (ComboTreeBoxColumn)OwningColumn;
                ComboTreeNode node = Nodes.ParsePath(Convert.ToString(formattedValue), column.PathSeparator, column.UseNodeNamesForPath);
                string displayValue;

                if (column.ShowPath)
                    displayValue = Convert.ToString(formattedValue);
                else
                    displayValue = (node != null) ? node.Text : String.Empty;

                Image img = ComboTreeBox.GetNodeImage(node, column.Images, column.ImageIndex, column.ImageKey, column.ExpandedImageIndex, column.ExpandedImageKey);

                Rectangle contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags = ComboTreeBox.TEXT_FORMAT_FLAGS | TextFormatFlags.PreserveGraphicsClipping;

                Rectangle imgBounds = (img == null)
                    ? new Rectangle(Point.Add(contentBounds.Location, new Size(1,0)), Size.Empty)
                    : new Rectangle(contentBounds.Left + 4, contentBounds.Top + (contentBounds.Height / 2 - img.Height / 2), img.Width, img.Height);

                Rectangle txtBounds = new Rectangle(imgBounds.Right, contentBounds.Top, contentBounds.Right - imgBounds.Right - 3, contentBounds.Height);

                if (img != null) graphics.DrawImage(img, imgBounds);

                TextRenderer.DrawText(graphics, displayValue, cellStyle.Font, txtBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }
开发者ID:zwolsman,项目名称:proftaak,代码行数:49,代码来源:ComboTreeBoxColumn.cs


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