protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle initCellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { //IEasyGridCell baseCell = GetSpanBaseCell(); //DataGridViewCell cell = baseCell as DataGridViewCell; cellStyle.BackColor = CellFunctions.BackColor(this); String text = this.Text; Rectangle textArea = getTextArea(initCellBounds); PaintCell(textArea, g); Rectangle buttonArea = getButtonArea(initCellBounds); //g.FillRectangle(Brushes.Gray, getButtonArea(initCellBounds)); CellFunctions.DrawLensBack(this, buttonArea, g, DataGridView.GridColor, false, this.Enabled); g.DrawString("...", _font, Brushes.Black, new Point(buttonArea.X + 5, buttonArea.Y)); //PaintCell(initCellBounds, g); /* * if (baseCell.Equals(this) == false) * { * //do nothing.. * * } * else * { * PaintCell(initCellBounds, g); * } */ paintParts = DataGridViewPaintParts.None; }
protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { //if (cellBounds.Y == 0) return; //CellFunctions.DrawPlainBackground(this, this.Enabled, cellBounds, g, rowIndex, this.Selected, this.DataGridView.GridColor); if (_visible) { if (_imageLayout != System.Windows.Forms.ImageLayout.Stretch && _imageLayout != System.Windows.Forms.ImageLayout.Zoom && (ImageFixedWidth > 0 || ImageFixedHeight > 0)) { paintParts = DataGridViewPaintParts.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.Focus; base.Paint(g, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); if (_selectedIndex > 0) { if (_imageLayout == System.Windows.Forms.ImageLayout.Center) { int wid = (ImageFixedWidth == 0) ? this.Images.ElementAt(_selectedIndex).Width : ImageFixedWidth; int hig = (ImageFixedHeight == 0) ? this.Images.ElementAt(_selectedIndex).Height : ImageFixedHeight; int x = cellBounds.Location.X + (cellBounds.Width + wid) / 2; int y = cellBounds.Location.Y + (cellBounds.Height + hig) / 2; g.DrawImage(this.Images.ElementAt(_selectedIndex), new Rectangle(x, y, wid, hig)); } else { int wid = (ImageFixedWidth == 0) ? this.Images.ElementAt(_selectedIndex).Width : ImageFixedWidth; int hig = (ImageFixedHeight == 0) ? this.Images.ElementAt(_selectedIndex).Height : ImageFixedHeight; int x = cellBounds.Location.X; int y = cellBounds.Location.Y + (cellBounds.Height + hig) / 2; g.DrawImage(this.Images.ElementAt(_selectedIndex), new Rectangle(x, y, wid, hig)); } } } else { //CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, rowIndex, Selected, _parent.GridColor); //this.Style.SelectionBackColor = CellFunctions.BackColor(this, this.RowIndex); cellStyle.SelectionBackColor = CellFunctions.BackColor(this); //this.Style.BackColor = CellFunctions.BackColor(this,this.RowIndex); cellStyle.BackColor = CellFunctions.BackColor(this); //paintParts = DataGridViewPaintParts.ContentForeground; paintParts = DataGridViewPaintParts.All;//.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.Focus|DataGridViewPaintParts.ContentForeground; base.Paint(g, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); } } else { //CellFunctions.DrawPlainBackground(this, this.Enabled, cellBounds, g, rowIndex, this.Selected, Color.Transparent); } }