If I have a normal DataGridView and I want to show only the horizontal lines, I apply the following code:
dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
Using the UI template Krypton for WinFroms, it is not working for me. I use:
kryptonDataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
And the lines still appear!
Did anyone come across this problem and solve it?
I know this is an old question, but I hope you can still find this useful:
Why your code doesn't work:
Well, KryptonDataGridView inherits from the DataGridView WinForms control, and by looking at the source code, you'll find that
KryptonDataGridView.CellBorderStyle
simply gets or sets the value ofbase.CellBorderStyle
which are not the same borders displayed by KryptonDataGridView.A lot of the inherited properties doesn't have an effect on Krypton controls (the
Font
property, for example). But in most cases, Krypton provides an alternative (with more features usually).Solution:
To replicate the behavior of
DataGridView.CellBorderStyle
, with KryptonDataGridView, you should use theDataCell.Border.DrawBorders
property of the appropriateState
:Result:
Hope that helps.