public void RePaint() { if (_parent != null && this.RowIndex >= _parent.FirstDisplayedScrollingRowIndex && this.ColumnIndex >= _parent.FirstDisplayedScrollingColumnIndex) { try { Rectangle rect = _parent.GetCellDisplayRectangle(this.ColumnIndex, this.RowIndex, true); if (rect.Width > 0 && rect.Height > 0) { PaintCell(rect, _parent.CreateGraphics()); _parent.InvalidateCell(this.ColumnIndex, this.RowIndex); } } catch { } //_parent.UpdateCellValue(this.ColumnIndex, this.RowIndex); } }
/* * protected override void PaintBorder(Graphics g, Rectangle clipBound, Rectangle drawRect, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle) * { * // base.PaintBorder(g, clipBound, drawRect, cellStyle, advancedBorderStyle); * int y = drawRect.Y + drawRect.Height-1; * g.DrawLine(new Pen(_parent.GridColor, 0.1f), drawRect.X, y, drawRect.X + drawRect.Width, y); * * * } */ /* * void DrawStringResizedForCellWid(SizeF size, Rectangle cellBounds, int textMargin, int textY, Graphics g) * { * Font font = new Font(_font, FontStyle.Regular); * if (size.Width > this.OwningColumn.Width) * { * SizeF Letter1 = g.MeasureString(Text[0].ToString(), _font); * if (this.OwningColumn.Width <= Letter1.Width)//이 경우에는 숨어있는 cell이라고 본다. loop문에 들어가면 무한루프가 된다. * { * } * else * { * while (size.Width > this.OwningColumn.Width) * { * font = new Font(FontFamily.GenericMonospace, font.Size - 0.5f);// new Font( font.FontFamily, font.Size - 0.5f);// font.Size = font.Size - 0.5f; * size = g.MeasureString(Text, font); * } * * g.DrawString(Text, font, _fontColor, cellBounds.X + textMargin, textY); * } * } * else * { * DrawSingleLine(cellBounds, g, size, textY, textMargin); * } * } */ /* * public int GetLinesOfATextLine(SizeF textSize) * { * int size = (int)(textSize.Width + _textMargin); * int lines = size / this.OwningColumn.Width; // 5/2 = 2 * if ((size % this.OwningColumn.Width) > 0) lines++; // 5%2 = 1 * * if (this.OwningColumn.Width <= 15)//이 경우에는 숨어있는 cell이라고 본다. loop문에 들어가면 무한루프가 된다. * { * lines = 1; * } * return lines; * } * * public int GetTextLines(String text) * { * Graphics g = _parent.CreateGraphics(); * String[] lines = text.Split("\n".ToCharArray()); * int numLines = 0; * * for (int i = 0; i < lines.Length; i++) * { * SizeF textSize = g.MeasureString(lines[i], _font); * numLines += GetLinesOfATextLine(textSize); * } * return numLines; * } */ public SizeF GetTextSize(String text) { Graphics g = _parent.CreateGraphics(); return(g.MeasureString(text, Font)); }