private void PaintCellBackground(Graphics graphics, Rectangle cellRect, CellStyleInfo style, bool canApplyInterior)
 {
     if (canApplyInterior && style.HasInterior)
     {
         Syncfusion.WinForms.Core.BrushPainter.FillRectangle(graphics, cellRect, style.Interior);
     }
     else
     {
         Brush backColor = new SolidBrush(style.BackColor);
         graphics.FillRectangle(backColor, cellRect);
         Syncfusion.ComponentModel.DisposeHelper.Dispose(ref backColor);
     }
 }
示例#2
0
        protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);

            //To set the rectangle for button in the cell.
            var rect = new Rectangle(cellRect.Location.X + cellRect.Width - 22, cellRect.Location.Y, 20, cellRect.Height);

            (column.GridColumn as GridTextButtonColumn).CellButton                   = new CellButton();
            (column.GridColumn as GridTextButtonColumn).CellButton.Image             = Image.FromFile(@"..\..\Images\icons.png");
            (column.GridColumn as GridTextButtonColumn).CellButton.TextImageRelation = TextImageRelation.ImageBeforeText;

            PropertyInfo highlightedItemProperty = (column.GridColumn as GridTextButtonColumn).CellButton.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance).Single(pi => pi.Name == "Bounds");

            highlightedItemProperty.SetValue((column.GridColumn as GridTextButtonColumn).CellButton, rect);

            //To draw the button in cell
            DrawButton(paint, cellRect, rect, "...", new ButtonCellStyleInfo(), column, rowColumnIndex);
        }
            protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
            {
                string[] date   = cellValue.Split();
                SizeF    size   = paint.MeasureString(date[0], style.Font.GetFont());
                float    height = (cellRect.Height - size.Height) / 2;

                paint.DrawString(date[0], style.Font.GetFont(), new SolidBrush(style.TextColor), cellRect.X, cellRect.Y + height);
                paint.DrawString(date[1], new Font(style.Font.Facename, style.Font.Size, FontStyle.Bold), new SolidBrush(style.TextColor), cellRect.X + size.Width, cellRect.Y + height);
            }
示例#4
0
        /// <summary>
        /// Sets the sample customization settings.
        /// </summary>
        private void SampleCustomization()
        {
            this.sfDataGrid1.AllowEditing        = true;
            this.sfDataGrid1.AllowGrouping       = true;
            this.sfDataGrid1.AutoGenerateColumns = false;

            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalDigits = 0;
            nfi.NumberGroupSizes    = new int[] { };

            OrderInfoRepository orderInfo = new OrderInfoRepository();

            this.sfDataGrid1.DataSource = orderInfo.GetOrdersDetails(30);
            this.sfDataGrid1.Columns.Add(new GridNumericColumn()
            {
                MappingName = "OrderID", HeaderText = "رقم التعريف الخاص بالطلب", NumberFormatInfo = nfi
            });
            this.sfDataGrid1.Columns.Add(new GridTextColumn()
            {
                MappingName = "ShipCity", HeaderText = "مدينة السفن"
            });
            this.sfDataGrid1.Columns.Add(new GridTextColumn()
            {
                MappingName = "ShipCountry", HeaderText = "السفينة البلد"
            });
            this.sfDataGrid1.Columns.Add(new GridDateTimeColumn()
            {
                MappingName = "ShippingDate", HeaderText = "السفينة البلد"
            });
            this.sfDataGrid1.Columns.Add(new GridNumericColumn()
            {
                MappingName = "Freight", HeaderText = "شحن", FormatMode = FormatMode.Currency
            });
            this.sfDataGrid1.Columns.Add(new GridCheckBoxColumn()
            {
                MappingName = "IsClosed", HeaderText = "مغلق", CheckBoxSize = new Size(13, 13)
            });

            #region Relation Creation
            GridViewDefinition viewDefinition = new GridViewDefinition();
            viewDefinition.RelationalColumn = "OrderDetails";
            SfDataGrid firstLevelSourceDataGrid = new SfDataGrid();
            firstLevelSourceDataGrid.AutoGenerateColumns = false;
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "OrderID", HeaderText = "رقم التعريف الخاص بالطلب", NumberFormatInfo = nfi
            });
            firstLevelSourceDataGrid.Columns.Add(new GridTextColumn()
            {
                MappingName = "Product", HeaderText = "المنتج"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridTextColumn()
            {
                MappingName = "CustomerCity", HeaderText = "مدينة العملاء"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "ProductID", HeaderText = "معرف المنتج", FormatMode = FormatMode.Numeric, NumberFormatInfo = nfi
            });
            //firstLevelSourceDataGrid.Columns.Add(new GridHyperlinkColumn() { MappingName = "HyperLink", HeaderText = "الارتباط التشعبي" });
            firstLevelSourceDataGrid.Columns.Add(new GridDateTimeColumn()
            {
                MappingName = "OrderDate", HeaderText = "تاريخ الطلب"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "UnitPrice", HeaderText = "سعر الوحدة", FormatMode = FormatMode.Currency
            });
            CellStyleInfo cellStyle = new CellStyleInfo();
            cellStyle.HorizontalAlignment = HorizontalAlignment.Right;
            firstLevelSourceDataGrid.Columns.Add(new GridUnboundColumn()
            {
                MappingName = "QuantitiesPrice", HeaderText = "المجموع الكلي", Expression = "UnitPrice * Quantity", CellStyle = cellStyle
            });
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "Discount", HeaderText = "خصم", FormatMode = FormatMode.Percent
            });
            firstLevelSourceDataGrid.Columns.Add(new GridImageColumn()
            {
                MappingName = "ImageLink", HeaderText = "بلد", ImageLayout = ImageLayout.Center
            });
            (firstLevelSourceDataGrid.Columns["ImageLink"] as GridImageColumn).CellStyle.VerticalAlignment   = VerticalAlignment.Center;
            (firstLevelSourceDataGrid.Columns["ImageLink"] as GridImageColumn).CellStyle.HorizontalAlignment = HorizontalAlignment.Center;
            viewDefinition.DataGrid = firstLevelSourceDataGrid;
            this.sfDataGrid1.DetailsViewDefinitions.Add(viewDefinition);

            firstLevelSourceDataGrid.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill;
            this.sfDataGrid1.AutoSizeColumnsMode         = AutoSizeColumnsMode.Fill;

            #endregion

            this.sfDataGrid1.HideEmptyGridViewDefinition = true;
        }
        /// <summary>
        /// Overridden to draw the spark line of the cell.
        /// </summary>
        /// <param name="graphics">The <see cref="T:System.Drawing.Graphics"/> that used to draw the spark line.</param>
        /// <param name="cellRect">The cell rectangle.</param>
        /// <param name="cellValue">The cell value.</param>
        /// <param name="style">The CellStyleInfo of the cell.</param>
        /// <param name="column">The DataColumnBase of the cell.</param>
        /// <param name="rowColumnIndex">The row and column index of the cell.</param>
        protected override void OnRender(Graphics graphics, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            using (SolidBrush brush = new SolidBrush(style.BackColor))
                graphics.FillRectangle(brush, cellRect);

            var sparklineColumn = column.GridColumn as GridSparklineColumn;

            this.Sparkline = new Syncfusion.Windows.Forms.Chart.SparkLine();
            var record = this.DataGrid.GetRecordAtRowIndex(rowColumnIndex.RowIndex);

            this.Sparkline.Source = GetSparklineSource(column.GridColumn.MappingName, record);
            this.Sparkline.Type   = sparklineColumn.SparklineType;
            this.Sparkline.Markers.ShowEndPoint      = true;
            this.Sparkline.Markers.ShowHighPoint     = true;
            this.Sparkline.Markers.ShowLowPoint      = true;
            this.Sparkline.Markers.ShowMarker        = true;
            this.Sparkline.Markers.ShowNegativePoint = true;
            this.Sparkline.Markers.ShowStartPoint    = true;
            this.Sparkline.Size     = cellRect.Size;
            this.Sparkline.Location = cellRect.Location;

            var smoothingMode = graphics.SmoothingMode;
            var clipBounds    = graphics.VisibleClipBounds;

            graphics.SetClip(cellRect);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            if (this.Sparkline.Type == SparkLineType.Line)
            {
                DrawSparkline(graphics, Sparkline);
            }
            else if (this.Sparkline.Type == SparkLineType.Column)
            {
                DrawSparkColumn(graphics, Sparkline);
            }
            else
            {
                DrawSparkWinLossColumn(graphics, Sparkline);
            }

            graphics.SmoothingMode = smoothingMode;
            graphics.SetClip(clipBounds);
        }
        /// <summary>
        /// Overridden to draw the rating of the cell.
        /// </summary>
        /// <param name="graphics">The <see cref="T:System.Drawing.Graphics"/> that used to draw the rating.</param>
        /// <param name="cellRect">The cell rectangle.</param>
        /// <param name="cellValue">The cell value.</param>
        /// <param name="style">The CellStyleInfo of the cell.</param>
        /// <param name="column">The DataColumnBase of the cell.</param>
        /// <param name="rowColumnIndex">The row and column index of the cell.</param>
        protected override void OnRender(Graphics graphics, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            using (SolidBrush brush = new SolidBrush(style.BackColor))
                graphics.FillRectangle(brush, cellRect);

            var RatingColumn = column.GridColumn as GridRatingColumn;

            RatingControl.Orientation = Orientationmode.Horizontal;
            RatingControl.Location    = cellRect.Location;
            var Width = RatingControl.Width;

            RatingControl.Orientation = Orientationmode.Horizontal;
            RatingControl.ItemsCount  = RatingColumn.ItemCount;
            RatingControl.Size        = cellRect.Size;
            RatingControl.Shape       = RatingColumn.Shape;
            int value = 0;

            if (int.TryParse(cellValue, out value))
            {
                RatingControl.Value = value;
            }
            RatingControl.ItemSelectionColor = RatingColumn.ItemSelectionColor;
            RatingControl.ItemBackColor      = RatingColumn.ItemBackColor;

            var smoothingMode = graphics.SmoothingMode;

            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            int       starHeight, starWidth;
            Rectangle drawArea;
            var       clipBounds = graphics.VisibleClipBounds;

            graphics.SetClip(cellRect);
            Rectangle[] m_Itemrectangle = new Rectangle[RatingControl.ItemsCount];

            var padding = 10;

            cellRect.X     += padding;
            cellRect.Width -= 2 * padding;
            Width           = cellRect.Width;

            starWidth  = 16;
            starHeight = 16;

            var startingPosition = (Width - ((RatingControl.ItemsCount * starWidth) + ((RatingControl.ItemsCount - 1) * RatingControl.Spacing))) / 2;

            drawArea = new Rectangle(cellRect.X + startingPosition, cellRect.Y + ((cellRect.Height / 2) - (starHeight / 2)), starWidth, starHeight);

            RatingControl.Location = new Point(drawArea.X, drawArea.Y);

            for (int i = 0; i < RatingControl.ItemsCount; ++i)
            {
                m_Itemrectangle[i].X      = drawArea.X - RatingControl.Spacing / 2;
                m_Itemrectangle[i].Y      = drawArea.Y;
                m_Itemrectangle[i].Width  = drawArea.Width + RatingControl.Spacing / 2;
                m_Itemrectangle[i].Height = drawArea.Height;

                if (RatingControl.Shape == Shapes.Circle)
                {
                    RatingControl.DrawCircle(graphics, drawArea, i);
                }
                else if (RatingControl.Shape == Shapes.Heart)
                {
                    RatingControl.DrawHeart(graphics, drawArea, i);
                }
                else if (RatingControl.Shape == Shapes.CustomImages)
                {
                    RatingControl.DrawCustomShapes(graphics, drawArea, i);
                }
                else
                {
                    RatingControl.DrawShape(graphics, drawArea, i);
                }

                drawArea.X += drawArea.Width + RatingControl.Spacing;
            }

            graphics.SetClip(clipBounds);
            graphics.SmoothingMode = smoothingMode;
        }
示例#7
0
        /// <summary>
        /// Sets the sample customization settings.
        /// </summary>
        private void SampleCustomization()
        {
            this.sfDataGrid1.AllowEditing        = true;
            this.sfDataGrid1.AllowGrouping       = true;
            this.sfDataGrid1.AutoGenerateColumns = false;

            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalDigits = 0;
            nfi.NumberGroupSizes    = new int[] { };

            OrderInfoRepository orderInfo = new OrderInfoRepository();

            this.sfDataGrid1.DataSource = orderInfo.GetOrdersDetails(30);
            this.sfDataGrid1.Columns.Add(new GridNumericColumn()
            {
                MappingName = "OrderID", HeaderText = "Order ID", NumberFormatInfo = nfi
            });
            this.sfDataGrid1.Columns.Add(new GridTextColumn()
            {
                MappingName = "CustomerID", HeaderText = "Customer ID"
            });
            this.sfDataGrid1.Columns.Add(new GridTextColumn()
            {
                MappingName = "ShipCity", HeaderText = "Ship City"
            });
            this.sfDataGrid1.Columns.Add(new GridTextColumn()
            {
                MappingName = "ShipCountry", HeaderText = "Ship Country"
            });
            this.sfDataGrid1.Columns.Add(new GridDateTimeColumn()
            {
                MappingName = "ShippingDate", HeaderText = "Shipping Date"
            });
            this.sfDataGrid1.Columns.Add(new GridNumericColumn()
            {
                MappingName = "Freight", HeaderText = "Freight", FormatMode = FormatMode.Currency
            });
            this.sfDataGrid1.Columns.Add(new GridCheckBoxColumn()
            {
                MappingName = "IsClosed", HeaderText = "Is Closed"
            });

            #region Relation Creation
            GridViewDefinition viewDefinition = new GridViewDefinition();
            viewDefinition.RelationalColumn = "OrderDetails";
            SfDataGrid firstLevelSourceDataGrid = new SfDataGrid();
            firstLevelSourceDataGrid.AutoGenerateColumns = false;
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "OrderID", HeaderText = "Order ID", NumberFormatInfo = nfi
            });
            firstLevelSourceDataGrid.Columns.Add(new GridTextColumn()
            {
                MappingName = "CustomerID", HeaderText = "Customer ID"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridTextColumn()
            {
                MappingName = "CustomerCity", HeaderText = "Customer City"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "ProductID", HeaderText = "Product ID", FormatMode = FormatMode.Numeric, NumberFormatInfo = nfi
            });
            firstLevelSourceDataGrid.Columns.Add(new GridHyperlinkColumn()
            {
                MappingName = "HyperLink", HeaderText = "HyperLink"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridDateTimeColumn()
            {
                MappingName = "OrderDate", HeaderText = "Order Date"
            });
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "UnitPrice", HeaderText = "Unit Price", FormatMode = FormatMode.Currency
            });
            CellStyleInfo cellStyle = new CellStyleInfo();
            cellStyle.HorizontalAlignment = HorizontalAlignment.Right;
            firstLevelSourceDataGrid.Columns.Add(new GridUnboundColumn()
            {
                MappingName = "QuantitiesPrice", HeaderText = "Grand Total", Expression = "UnitPrice * Quantity", CellStyle = cellStyle
            });
            firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn()
            {
                MappingName = "Discount", HeaderText = "Discount", FormatMode = FormatMode.Percent
            });
            firstLevelSourceDataGrid.Columns.Add(new GridImageColumn()
            {
                MappingName = "ImageLink", HeaderText = "Country", ImageLayout = ImageLayout.Center
            });
            (firstLevelSourceDataGrid.Columns["ImageLink"] as GridImageColumn).CellStyle.VerticalAlignment   = VerticalAlignment.Center;
            (firstLevelSourceDataGrid.Columns["ImageLink"] as GridImageColumn).CellStyle.HorizontalAlignment = HorizontalAlignment.Center;
            viewDefinition.DataGrid = firstLevelSourceDataGrid;
            this.sfDataGrid1.DetailsViewDefinitions.Add(viewDefinition);
            #endregion

            this.sfDataGrid1.HideEmptyGridViewDefinition = true;
        }
        protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            ProgressBar.CustomText = cellValue + "%";
            ProgressBar.TextStyle  = ProgressBarTextStyles.Custom;
            decimal decimalvalue = decimal.Parse(cellValue);
            var     intvalue     = decimal.ToInt32(decimalvalue);

            cellValue = intvalue.ToString();
            base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);
        }
示例#9
0
        protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            string check = this.spellchecker.SpellCheck(cellValue.ToString());

            //Checking whether the result has suggestions.
            if (check != "")
            {
                style.Font.Underline = true;
            }
            base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);
        }
 protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
 {
     if (rowColumnIndex.RowIndex == DataGrid.CurrentCell.RowIndex)
     {
         style.BackColor = ColorTranslator.FromHtml("#0078d2");
     }
     else
     {
         style.BackColor = DataGrid.Style.RowHeaderStyle.BackColor;
     }
     base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);
 }
示例#11
0
        protected override void HighlightSearchText(Graphics paint, DataColumnBase column, CellStyleInfo style,
                                                    Rectangle bounds, string cellValue, RowColumnIndex rowColumnIndex)
        {
            if (AllowHighlightSearchText && !string.IsNullOrEmpty(SearchText))
            {
                if (column != null && (SearchColumns.Count > 0 && !SearchColumns.Contains(column.GridColumn.MappingName)))
                {
                    return;
                }

                var      searchText     = SearchText;
                string[] metaCharacters = { "\\", "^", "$", "{", "}", "[", "]", "(", ")", ".", "*", "+", "?", "|", "<", ">", "-", "&" };
                if (metaCharacters.Any(searchText.Contains))
                {
                    for (int i = 0; i < metaCharacters.Length; i++)
                    {
                        if (searchText.Contains(metaCharacters[i]))
                        {
                            searchText = searchText.Replace(metaCharacters[i], @"\" + metaCharacters[i]);
                        }
                    }
                }

                searchText = "^(" + searchText + ")$";

                //Gets the list of indexes that match with the search text.
                List <int> matchList = Regex.Matches(cellValue, searchText, this.AllowCaseSensitiveSearch ? RegexOptions.None : RegexOptions.IgnoreCase)
                                       .Cast <Match>()
                                       .Select(s => s.Index).ToList();



                if (matchList.Count > 0 && bounds.Width > 0)
                {
                    StringFormat format = new StringFormat(StringFormat.GenericDefault);

                    List <CharacterRange[]> characterRangeList = new List <CharacterRange[]>();

                    //Used 32 as CharacterRangeLength to avoid System.OverFlowExcepion
                    //in StringFormat.SetMeasurableCharacterRanges which occurs if the CharacterRange length is more than 32.
                    int characterRangeLength = 32;
                    int count      = matchList.Count / characterRangeLength;
                    int range      = matchList.Count % characterRangeLength;
                    int startIndex = 0;

                    if (count > 0)
                    {
                        for (int index = 0; index < count; index++)
                        {
                            CharacterRange[] characterRange = new CharacterRange[characterRangeLength];

                            for (int i = 0; i < characterRangeLength; i++)
                            {
                                characterRange[i] = new CharacterRange(matchList[startIndex], SearchText.Length);
                                startIndex++;
                            }

                            characterRangeList.Add(characterRange);
                            characterRange = null;
                        }
                    }

                    if (range > 0)
                    {
                        CharacterRange[] characterRange = new CharacterRange[range];
                        for (int i = 0; i < range; i++)
                        {
                            characterRange[i] = new CharacterRange(matchList[startIndex], SearchText.Length);
                            startIndex++;
                        }

                        characterRangeList.Add(characterRange);
                        characterRange = null;
                    }

                    //VerticalAlignment
                    format.LineAlignment = ConvertToStringAlignment(style.VerticalAlignment);

                    //HorizontalAlignment
                    format.Alignment = ConvertToStringAlignment(style.HorizontalAlignment);

                    if (!column.GridColumn.AllowTextWrapping)
                    {
                        format.FormatFlags = StringFormatFlags.NoWrap;
                        format.Trimming    = column.GridColumn.TextTrimming;
                    }

                    if (DataGrid.RightToLeft == RightToLeft.Yes)
                    {
                        format.FormatFlags = StringFormatFlags.DirectionRightToLeft;
                    }

                    foreach (var characterRange in characterRangeList)
                    {
                        //Set the range of characters to be measured.
                        format.SetMeasurableCharacterRanges(characterRange);

                        //Gets the regions of the measurable characters applied to the string format for the given text with in the text bounds.
                        Region[] regions = paint.MeasureCharacterRanges(cellValue, style.GetFont(), bounds, format);

                        RectangleF[] fillRectangle = new RectangleF[regions.Length];
                        for (int i = 0; i < regions.Length; i++)
                        {
                            fillRectangle[i] = regions[i].GetBounds(paint);
                        }

                        var highlightColor = SearchColor;
                        if (this.CurrentRowColumnIndex == rowColumnIndex)
                        {
                            highlightColor = SearchHighlightColor;
                        }

                        // Highlights the search text based on the
                        using (Brush brush = new SolidBrush(highlightColor))
                            paint.FillRectangles(brush, fillRectangle);
                    }

                    characterRangeList.Clear();
                    characterRangeList = null;
                    matchList.Clear();
                    matchList = null;
                }
            }
        }
示例#12
0
        protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            int       starHeight, starWidth;
            Rectangle drawArea;

            var padding = 5;

            starWidth  = 16;
            starHeight = 16;

            var RadioButtonColumn = column.GridColumn as GridRadioButtonColumn;

            drawArea = new Rectangle(cellRect.X + padding, cellRect.Y + ((cellRect.Height / 2) - (starHeight / 2)), starWidth, starHeight);

            RadioButtonCollection = new List <GridCellRadioButton>();
            for (int i = 0; i < RadioButtonColumn.ItemCount; i++)
            {
                var radioButton = new GridCellRadioButton();

                radioButton.Location = new Point(drawArea.X, drawArea.Y);
                radioButton.Width    = starWidth;
                radioButton.Height   = starHeight;

                //Draw outer border of RadioButton
                radioButton.DrawBorder(paint, Color.Black, drawArea, radioButton);

                Point point = new Point(drawArea.X + drawArea.Width + 2, drawArea.Y);
                Font  font  = style.GetFont() != Control.DefaultFont ? style.GetFont() : Control.DefaultFont;

                int value       = i;
                var buttonValue = ((Options)value).ToString();

                //Draw string for RadioButton
                paint.DrawString(buttonValue, font, new SolidBrush(Color.Gray), point);
                if (buttonValue.Equals(cellValue))
                {
                    radioButton.DrawSelectedCheckMark(paint, drawArea, radioButton, Color.Black, Color.Black);
                }
                //Add RadioButton to Cell
                RadioButtonCollection.Add(radioButton);

                //Set the start point for next RadioButton
                Size stringlenth = TextRenderer.MeasureText((RadioOptions = 0).ToString(), font);
                drawArea.X += drawArea.Width + 10 + stringlenth.Width;
            }
        }
示例#13
0
        protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, Syncfusion.WinForms.GridCommon.ScrollAxis.RowColumnIndex rowColumnIndex)
        {
            base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);
            var dropDownbuttonRect = new Rectangle(cellRect.X + cellRect.Width - 17, cellRect.Y + (cellRect.Height / 2), 8, 4);

            paint.DrawLine(new Pen(Color.Gray), dropDownbuttonRect.X, dropDownbuttonRect.Y, dropDownbuttonRect.X + (dropDownbuttonRect.Width / 2), dropDownbuttonRect.Y + dropDownbuttonRect.Height);
            paint.DrawLine(new Pen(Color.Gray), dropDownbuttonRect.X + dropDownbuttonRect.Width, dropDownbuttonRect.Y, dropDownbuttonRect.X + (dropDownbuttonRect.Width / 2), dropDownbuttonRect.Y + dropDownbuttonRect.Height);
        }
 protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
 {
     // To draw background for the Expander cell.
     PaintCellBackground(paint, cellRect, style, true);
 }
        protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
        {
            if (column.GridColumn.MappingName == "IsClosed")
            {
                DataRowBase dataRow = (DataRowBase)column.GetType().GetProperty("DataRow", System.Reflection.BindingFlags.Instance |
                                                                                System.Reflection.BindingFlags.NonPublic).GetValue(column);

                if ((dataRow.RowData as OrderInfo).Quantity > 50)
                {
                    paint.FillRectangle(new SolidBrush(style.BackColor), cellRect);
                }
                else
                {
                    base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);
                }
            }
        }