本文整理汇总了C#中System.Windows.Forms.DataGridViewAdvancedBorderStyle类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewAdvancedBorderStyle类的具体用法?C# DataGridViewAdvancedBorderStyle怎么用?C# DataGridViewAdvancedBorderStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewAdvancedBorderStyle类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewAdvancedBorderStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Paint
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
var buttonRectangle = new Rectangle(cellBounds.X + 2, cellBounds.Y + 2, cellBounds.Width - 4, cellBounds.Height - 4);
base.Paint(graphics, clipBounds, buttonRectangle, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
var imageRectangle = new Rectangle(cellBounds.X + 6, cellBounds.Y + 6, _detailImage.Width, _detailImage.Height);
graphics.DrawImage(_detailImage, imageRectangle);
}
示例2: Paint
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
try
{
int progressVal = (int)value;
if(progressVal < 0) progressVal = 0;
if(progressVal > 100) progressVal = 100;
float percentage = ((float)progressVal / 100.0f);
Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
Brush barColorBrush = new SolidBrush(GetColorBetween(cellStyle.BackColor,
cellStyle.ForeColor, progressVal == 100 ? 0.2f : 0.3f));
base.Paint(g, clipBounds, cellBounds,
rowIndex, cellState, value, formattedValue, errorText,
cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
var s = progressVal.ToString() + "%";
var sz = g.MeasureString(s, cellStyle.Font);
int dy = (cellBounds.Height - this.DataGridView.RowTemplate.Height) / 2;
g.FillRectangle(barColorBrush, cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
g.DrawString(s, cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - sz.Width / 2 - 5, cellBounds.Y + 2 + dy);
}
catch (Exception e) { }
}
示例3: Paint
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
Tuple<int, string> updateInfo = (Tuple<int, string>)value;
int progressVal = updateInfo.Item1;
string message = updateInfo.Item2;
float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
// Draws the cell grid
base.Paint(g, clipBounds, cellBounds,
rowIndex, cellState, value, formattedValue, errorText,
cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
if (percentage > 0.0)
{
// Draw the progress bar and the text
g.FillRectangle(new SolidBrush(Color.FromArgb(163, 189, 242)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
g.DrawString(message, cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 2);
}
else
{
// draw the text
if (this.DataGridView.CurrentRow.Index == rowIndex)
g.DrawString(message, cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 6, cellBounds.Y + 2);
else
g.DrawString(message, cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 2);
}
}
示例4: Paint
protected override void Paint(Graphics graphics,
Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
DataGridViewElementStates elementState, object value,
object formattedValue, string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
// The button cell is disabled, so paint the border,
// background, and disabled button for the cell.
if (!this.enabledValue)
{
// Draw the cell background, if specified.
if ((paintParts & DataGridViewPaintParts.Background) ==
DataGridViewPaintParts.Background)
{
SolidBrush cellBackground =
new SolidBrush(cellStyle.BackColor);
graphics.FillRectangle(cellBackground, cellBounds);
cellBackground.Dispose();
}
// Draw the cell borders, if specified.
if ((paintParts & DataGridViewPaintParts.Border) ==
DataGridViewPaintParts.Border)
{
PaintBorder(graphics, clipBounds, cellBounds, cellStyle,
advancedBorderStyle);
}
// Calculate the area in which to draw the button.
Rectangle buttonArea = cellBounds;
Rectangle buttonAdjustment =
this.BorderWidths(advancedBorderStyle);
buttonArea.X += buttonAdjustment.X;
buttonArea.Y += buttonAdjustment.Y;
buttonArea.Height -= buttonAdjustment.Height;
buttonArea.Width -= buttonAdjustment.Width;
// Draw the disabled button.
ButtonRenderer.DrawButton(graphics, buttonArea, PushButtonState.Disabled);
// Draw the disabled button text.
if (this.FormattedValue is String)
{
TextRenderer.DrawText(graphics,
(string)this.FormattedValue,
this.DataGridView.Font,
buttonArea, enabledValue ? SystemColors.ControlText : SystemColors.GrayText);
}
}
else
{
// The button cell is enabled, so let the base class
// handle the painting.
base.Paint(graphics, clipBounds, cellBounds, rowIndex,
elementState, value, formattedValue, errorText,
cellStyle, advancedBorderStyle, paintParts);
}
}
示例5: Paint
protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
try
{
int progressVal = (int)value;
float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
// Draws the cell grid
base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
// Draw the progress bar and the text
g.FillRectangle(new SolidBrush(Color.FromArgb(8, 142, 6)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
string text = Value.ToString() + "%";
Font f = cellStyle.Font;
SizeF len = g.MeasureString(text, f);
SolidBrush foreColor = new SolidBrush(cellStyle.ForeColor);
if (DataGridView.Rows[rowIndex].Selected)
foreColor = new SolidBrush(cellStyle.SelectionForeColor);
Point location = new Point(Convert.ToInt32(cellBounds.X + ((cellBounds.Width / 2) - len.Width / 2)), Convert.ToInt32(cellBounds.Y + ((cellBounds.Height / 2) - len.Height / 2)));
g.DrawString(text, f, foreColor, location);
}
catch (Exception ex)
{
logger.Error(ex, "Error painting cell");
}
}
示例6: Paint
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
var fillRectangle = new Rectangle(cellBounds.X, cellBounds.Y, cellBounds.Width - 1, cellBounds.Height - 1);
var stringRectangle = new Rectangle(cellBounds.X + 5, cellBounds.Y + 3, cellBounds.Width - 8, cellBounds.Height - 8);
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.FillRectangle(new SolidBrush(Color.FromArgb(215, 228, 242)),
fillRectangle);
graphics.DrawLine(new Pen(Color.FromArgb(153, 180, 209), 1),
new Point(cellBounds.X + cellBounds.Width - 1, cellBounds.Y),
new Point(cellBounds.X + cellBounds.Width - 1, cellBounds.Y + cellBounds.Height - 1));
graphics.DrawLine(new Pen(Color.FromArgb(153, 180, 209), 1),
new Point(cellBounds.X, cellBounds.Y + cellBounds.Height - 1),
new Point(cellBounds.X + cellBounds.Width - 1, cellBounds.Y + cellBounds.Height - 1));
//var pen = new Pen(new LinearGradientBrush(new Rectangle(1, 1, 1, 1),
// Color.FromArgb(0, 0, 0),
// Color.FromArgb(200, 200, 200),
// LinearGradientMode.Horizontal))
//{
// DashCap = DashCap.Round,
// Width = 1
//};
//graphics.DrawLine(pen,
// new Point(cellBounds.X + 7, cellBounds.Y + 7),
// new Point(cellBounds.X + cellBounds.Width - 7, cellBounds.Y + cellBounds.Height - 7));
//graphics.DrawLine(pen,
// new Point(cellBounds.X + cellBounds.Width - 7, cellBounds.Y + 7),
// new Point(cellBounds.X + 7, cellBounds.Y + cellBounds.Height - 7));
graphics.DrawString("X",
new Font("Comic Sans MS", 9.0f, FontStyle.Regular),
new SolidBrush(Color.FromArgb(0, 0, 0)),
stringRectangle);
}
示例7: Paint
protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
int progressVal = 0;
string label = String.Empty;
// get progress values
if (value != null && value.GetType() == typeof(ProgressState))
{
ProgressState s = (ProgressState)value;
progressVal = s.CurrentValue;
label = s.CurrentState;
if (s.ShowProgressBar == false || String.IsNullOrEmpty(label) == false)
progressVal = 0;
if (s.HasError)
this.ErrorText = s.ErrorText;
}
// Draws the cell grid
base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
// draw progress bar
float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
if (percentage > 0.0)
{
using (Brush highlightBrush = new SolidBrush(SystemColors.Highlight))
g.FillRectangle(highlightBrush, cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
}
// draw text
if (String.IsNullOrEmpty(label) == false)
{
using (Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor))
g.DrawString(label, cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 4);
}
}
示例8: Paint
protected override void Paint(Graphics graphics,
Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
DataGridViewElementStates dataGridViewElementState,
object value, object formattedValue, string errorText,
DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value,
formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds);
CheckBoxRegion = new Rectangle(
cellBounds.Location.X + 1,
cellBounds.Location.Y + 2,
25, cellBounds.Size.Height - 4);
if (this.checkAll)
ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Checked);
else
ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Normal);
Rectangle normalRegion =
new Rectangle(
cellBounds.Location.X + 1 + 25,
cellBounds.Location.Y,
cellBounds.Size.Width - 26,
cellBounds.Size.Height);
graphics.DrawString(value.ToString(), cellStyle.Font, new SolidBrush(cellStyle.ForeColor), normalRegion);
}
示例9: Paint
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
// the base Paint implementation paints the check box
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
// Get the check box bounds: they are the content bounds
Rectangle contentBounds = this.GetContentBounds(rowIndex);
// Compute the location where we want to paint the string.
Point stringLocation = new Point();
// Compute the Y.
// NOTE: the current logic does not take into account padding.
stringLocation.Y = cellBounds.Y + 2;
// Compute the X.
// Content bounds are computed relative to the cell bounds
// - not relative to the DataGridView control.
stringLocation.X = cellBounds.X + contentBounds.Right + 2;
// Paint the string.
if (this.Label == null)
{
DataGridViewCheckBoxWithLabelColumn col = (DataGridViewCheckBoxWithLabelColumn) this.OwningColumn;
this.label = col.Label;
}
graphics.DrawString(this.Label, Control.DefaultFont, System.Drawing.Brushes.Red, stringLocation);
}
示例10: Paint
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) {
if(this.fNowCalculating) {
this.PaintBackGround(graphics, advancedBorderStyle, cellStyle, cellBounds);
paintParts &= ~(DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.Background);
}
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
}
示例11: Paint
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)
{
if (Columns.Count > rowIndex)
{
Column c = Columns[rowIndex];
if (c.PrimaryKey)
{
Bitmap bmp = rowIndex == DataGridView.CurrentRow.Index ?
Resources.ArrowKey : Resources.Key;
bmp.MakeTransparent();
paintParts &= ~DataGridViewPaintParts.ContentBackground;
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
value, formattedValue, errorText, cellStyle, advancedBorderStyle,
paintParts);
Rectangle r = cellBounds;
r.Offset(bmp.Width / 2, bmp.Height / 2);
r.Width = bmp.Width;
r.Height = bmp.Height;
graphics.DrawImage(bmp, r);
return;
}
}
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
value, formattedValue, errorText, cellStyle, advancedBorderStyle,
paintParts);
}
示例12: Paint
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)
{
if (Image != null)
{
base.Paint(graphics, clipBounds,
new Rectangle(cellBounds.X + Image.Width, cellBounds.Y, cellBounds.Width - Image.Height,cellBounds.Height),
rowIndex, cellState, value, formattedValue,errorText, cellStyle, advancedBorderStyle, paintParts);
if ((cellState & DataGridViewElementStates.Selected) != 0)
{
graphics.FillRectangle(
new SolidBrush(this.DataGridView.DefaultCellStyle.SelectionBackColor)
, cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
}
else
{
graphics.FillRectangle(new SolidBrush(this.DataGridView.DefaultCellStyle.BackColor),
cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
}
graphics.DrawImage(Image, cellBounds.X, cellBounds.Y+2, Image.Width,
Math.Min(Image.Height,cellBounds.Height));
}
else
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
}
}
示例13: Paint
//绘制列头checkbox
protected override void Paint(System.Drawing.Graphics graphics,
System.Drawing.Rectangle clipBounds,
System.Drawing.Rectangle cellBounds,
int rowIndex,
DataGridViewElementStates dataGridViewElementState,
object value,
object formattedValue,
string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex,
dataGridViewElementState, value,
formattedValue, errorText, cellStyle,
advancedBorderStyle, paintParts);
Point p = new Point();
Size s = CheckBoxRenderer.GetGlyphSize(graphics,
System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
p.X = cellBounds.Location.X + (cellBounds.Width / 2) - (s.Width / 2) - 1;//列头checkbox的X坐标
p.Y = cellBounds.Location.Y + (cellBounds.Height / 2) - (s.Height / 2);//列头checkbox的Y坐标
_cellLocation = cellBounds.Location;
checkBoxLocation = p;
checkBoxSize = s;
if (_checked)
_cbState = CheckBoxState.CheckedNormal;
else
_cbState = CheckBoxState.UncheckedNormal;
CheckBoxRenderer.DrawCheckBox(graphics, checkBoxLocation, _cbState);
}
示例14: PaintBackGround
private void PaintBackGround(Graphics graphics, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewCellStyle cellStyle, Rectangle cellBounds) {
Rectangle rectangle = base.BorderWidths(advancedBorderStyle);
Rectangle rect = cellBounds;
rect.Offset(rectangle.X, rectangle.Y);
rect.Width -= rectangle.Right;
rect.Height -= rectangle.Bottom;
using(SolidBrush brush = new SolidBrush(cellStyle.BackColor)) {
graphics.FillRectangle(brush, rect);
}
if(this.lFileSize <= 0L) {
return;
}
Rectangle bounds = rect;
double num = ((double)this.progressValue) / ((double)this.lFileSize);
bounds.Width = (int)(bounds.Width * num);
if(VisualStyleRenderer.IsSupported) {
try {
new VisualStyleRenderer(VisualStyleElement.ProgressBar.Chunk.Normal).DrawBackground(graphics, bounds);
goto Label_00E1;
}
catch {
goto Label_00E1;
}
}
using(SolidBrush brush2 = new SolidBrush(SystemColors.Highlight)) {
graphics.FillRectangle(brush2, bounds);
}
Label_00E1:
using(StringFormat format = new StringFormat()) {
format.Alignment = format.LineAlignment = StringAlignment.Center;
using(SolidBrush brush3 = new SolidBrush(cellStyle.ForeColor)) {
graphics.DrawString(((int)(num * 100.0)) + "%", cellStyle.Font, brush3, rect, format);
}
}
}
示例15: Paint
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)
{
if (this.DataGridView == null)
{
return;
}
// First paint the borders and background of the cell.
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
paintParts & ~(DataGridViewPaintParts.ErrorIcon | DataGridViewPaintParts.ContentForeground));
IRulesBoxLine myLine = Value as IRulesBoxLine;
myLine.Selected = this.Selected;
myLine.Paint(graphics, cellStyle.Font, cellBounds.Left, cellBounds.Top);
}