Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147758 | Sep 23,2019 12:15 PM UTC | Oct 1,2019 01:56 PM UTC | WinForms | 10 |
![]() |
Tags: GridGroupingControl |
//Event triggering
gridGroupingControl1.TableControlDrawCell += GridGroupingControl1_TableControlDrawCell;
//Event subscription
private void GridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
if (e.Inner.Style.CellType == "CheckBox")
{
Rectangle rect = e.Inner.Bounds;
Rectangle circleRect = new Rectangle(rect.X + 2, rect.Y + 2, 14, 14);
//To draw the circles
e.Inner.Graphics.DrawEllipse(Pens.Black, circleRect);
circleRect.Inflate(-3, -3);
e.Inner.Graphics.DrawEllipse(Pens.Black, circleRect);
//To fil the circle if the cell state is checked.
if(e.Inner.Style.CellValue.ToString() == "true")
e.Inner.Graphics.FillEllipse(Brushes.Black, circleRect);
else
e.Inner.Graphics.FillEllipse(new SolidBrush(e.Inner.Style.BackColor), circleRect);
//To restrict drawing the check box from base.
e.Inner.Cancel = true;
}
} |
//Event subscription
private void GridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
if (e.Inner.Style.CellType == "CheckBox")
{
Rectangle rect = e.Inner.Bounds;
Rectangle circleRect = new Rectangle(rect.X + 2, rect.Y + 2, 11, 11);
using (Pen pen = new Pen(Off2007Colors.CheckBoxOuterBorderColorHot))
{
//To draw the circles
e.Inner.Graphics.DrawEllipse(pen, circleRect);
circleRect.Inflate(-2, -2);
e.Inner.Graphics.DrawEllipse(pen, circleRect);
}
LinearGradientBrush br = new LinearGradientBrush(circleRect, Color.FromArgb(198, 235, 254), Color.FromArgb(8, 130, 198), LinearGradientMode.ForwardDiagonal);
//To fil the circle if the cell state is checked.
if (e.Inner.Style.CellValue.ToString() == "true")
e.Inner.Graphics.FillEllipse(br, circleRect);
else
e.Inner.Graphics.FillEllipse(new SolidBrush(e.TableControl.ThemeStyle.RadioButtonStyle.CheckedColor), circleRect);
//To restrict drawing the check box from base.
e.Inner.Cancel = true;
}
} |
private void GridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
if (e.Inner.Style.CellType == "CheckBox")
{
Rectangle rect = e.Inner.Bounds;
int checkBoxPosition = (rect.Width - 16) / 2;
Rectangle circleRect = new Rectangle(rect.X + checkBoxPosition, rect.Y + 2, 11, 11);
using (Pen pen = new Pen(Off2007Colors.CheckBoxOuterBorderColorHot))
{
//To draw the circles
e.Inner.Graphics.DrawEllipse(pen, circleRect);
circleRect.Inflate(-2, -2);
e.Inner.Graphics.DrawEllipse(pen, circleRect);
}
//Some code
e.Inner.Cancel = true;
}
} |
protected override void DrawCheckBox(Graphics g, Rectangle clientBounds, GridStyleInfo style, ButtonState state, ContentAlignment align, string text, Font font)
{
GridTableControl tb = this.Grid as GridTableControl;
if(tb != null)
{
if(tb.Table.RelationParentTable == null)
{
base.DrawCheckBox(g, clientBounds, style, state, align, text, font);
}
else
{
int checkBoxPosition = (clientBounds.Width - 16) / 2;
Rectangle circleRect = new Rectangle(clientBounds.X + checkBoxPosition, clientBounds.Y + 2, 17, 17);
//To draw the radio button for child table
this.Grid.Model.Options.GridVisualStylesDrawing.DrawRadioStyle(g, circleRect, state);
}
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.