Hi,
I searched a lot about changing the DataGridView cell borders. BYTES helped me so I will write down the solution:
1. You should override the class DataGridViewTex tBoxCell, and the new class should have a property of type DataGridViewAdv ancedBorderStyl e, this property you will change from the outside:
2. You will override also the PaintBorder, and Paint methods in a way that they will get the new property instead of the default one.
3. Thats it, all you have to do is to use your own overriden cell class for adding new cells in the rows.
-------------------------------------
here is the overriden class:
class CustomDataGridV iewCell : DataGridViewTex tBoxCell
{
private DataGridViewAdv ancedBorderStyl e _style;
public CustomDataGridV iewCell(): base()
{
_style = new DataGridViewAdv ancedBorderStyl e();
_style.Bottom = DataGridViewAdv ancedCellBorder Style.None;
_style.Top = DataGridViewAdv ancedCellBorder Style.None;
_style.Left = DataGridViewAdv ancedCellBorder Style.None;
_style.Right = DataGridViewAdv ancedCellBorder Style.None;
}
public DataGridViewAdv ancedBorderStyl e AdvancedBorderS tyle
{
get { return _style; }
set
{
_style.Bottom = value.Bottom;
_style.Top = value.Top;
_style.Left = value.Left;
_style.Right = value.Right;
}
}
protected override void PaintBorder(Gra phics graphics, Rectangle clipBounds, Rectangle bounds, DataGridViewCel lStyle cellStyle, DataGridViewAdv ancedBorderStyl e advancedBorderS tyle)
{
base.PaintBorde r(graphics, clipBounds, bounds, cellStyle, _style);
}
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewEle mentStates cellState, object value, object formattedValue, string errorText, DataGridViewCel lStyle cellStyle, DataGridViewAdv ancedBorderStyl e advancedBorderS tyle, DataGridViewPai ntParts paintParts)
{
base.Paint(grap hics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, _style, paintParts);
}
}