My grid is a readonly grid and with FullRow Selection mode. But still are the cells highlighted when i'm clicking in the grid. Look at the attached screenshot.
How can I disable this highlighting ?
I have tried with this code, but still the cell is "in a way" highlighted..
if
(e.CellElement.IsCurrent)
{
e.CellElement.DrawFill =
false
;
e.CellElement.DrawBorder =
false
;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
}
BTW: The EnableHotTracking is truned of.
Regards
Svein Thomas
15 Answers, 1 is accepted
If you are calling this code from the CellFormatting event, then the result should be as per the attached screenshot. Even though it doesn't draw the border, you can still see that it is the current cell (slightly) as there are some other properties that are different (BorderBoxStyle, Shadows etc).
From the look of it, your event is not being called. Ensure you have set up the event handler as shown
this
.radGridView1.CellFormatting +=
new
Telerik.WinControls.UI.CellFormattingEventHandler(
this
.radGridView1_CellFormatting);
private
void
radGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(e.CellElement.IsCurrent)
{
e.CellElement.DrawFill =
false
;
e.CellElement.DrawBorder =
false
;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
}
}
hope that helps
Richard
The picture is not with the event attached, that is correct.
But even when i do attach this event, i still can see a difference in the cell content when clicking the cell. The texts in the cell moves a bit... please try it and you see what i mean...
Svein Thomas
As mentioned in my previous post, if you want it to truly look alike, then there are a few more properties to set. It looks as though you are using the Default theme, so I can give you the settings for those, though it could also be done of course by definin gyour own theme using the Visual stle Builder.
The non selected cells, still have a border, but are defined as this..
private
void
radGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(e.CellElement.IsCurrent)
{
e.CellElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.FourBorders;
e.CellElement.BorderTopColor = Color.FromArgb(255, 190, 106);
e.CellElement.BorderTopShadowColor = Color.FromArgb(255, 245, 162);
e.CellElement.BorderBottomColor = Color.FromArgb(255, 190, 106);
e.CellElement.BorderBottomShadowColor = Color.FromArgb(255, 245, 162);
}
else
{
e.CellElement.ResetValue(LightVisualElement.BorderBoxStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BorderTopColorProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BorderTopShadowColorProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BorderBottomColorProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BorderBottomShadowColorProperty, Telerik.WinControls.ValueResetFlags.Local);
}
Hope that helps but let me know if you have further questions
Richard
Did this help? If so, please remember to mark as answer. If you need further help, just let me know.
Thanks
Richard
Regards
Svein Thomas
Glad that helped. The cell borders are still there on the other cells, but they are just styled differently under the default theme. In this case we are just changing the style of the border to equal the other cells. You can of course though define your own theme so all cells on a selected row would remain the same.
Let me know if you have any other questions
Richard
I would be happy if you would guide me on how to change the theme to do this. I already have a customized theme, and i tried to figure out where to set this settings with no luck.
Regards
Svein Thomas
To be very honest, VSB is an area that is weaker in my knowledge. I must get to know it better.
I have attaached a screenshot of the area that I beleive that you would have to change and the properties that you would need to change are the ones that are detailed in my previous reply.
I hope this helps, but if you think I might be able to assist you further, do just let me know.
Richard
edit// attaching image
I suggest that you go through the ControlDefault theme and see how the cell styles are applied in all states. Then you should be able to delete these states (or unassociate respective repositories) in your theme. You can read the online documentation regarding the process of opening a predefined theme. In addition, you can read how to use Visual Style Builder here.
Kind regards,Svett
the Telerik team
void
LiquidRadGridView_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(e.CellElement !=
null
)
{
if
(e.CellElement.IsCurrent)
{
e.CellElement.IsCurrent =
false
;
e.CellElement.IsCurrentColumn =
false
;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
}
}
}
Hi,
I have an issue that when a form(I have attached the screenshot) is loaded from another form and focus goes to a particular cell in RadGridView it does not selected(Highlighted with blue color).So that when i want to change the text,i simply do double left mouse click on the cell.Here i want to avoid mouse click,and do it programmatically select the text on the cell.Here is the code snippet:
private
void
frmProductSelect_Load(
object
sender, EventArgs e)
{
dgvProductSelect.Focus();
dgvProductSelect.CurrentRow = dgvProductSelect.Rows[0];
dgvProductSelect.CurrentColumn = dgvProductSelect.Columns[
"Quantity"
];
dgvProductSelect.Rows[0].Cells[
"Quantity"
].Value = Convert.ToDecimal(rlbl_SalesQty.Text);
dgvProductSelect.Rows[0].Cells[
"Quantity"
].BeginEdit();
}
I think you got my problem.If you want any clarification,please let me know.
Regards
ABDUL HAFEEL
Thank you for writing.
If I understand correctly, you would like to start editing the cell as soon as your form loads. The cell`s text will be selected by default. However, please consider setting the current row and column in the Shown event of your form:
protected
override
void
OnShown(EventArgs e)
{
base
.OnShown(e);
this
.radGridView1.CurrentRow =
this
.radGridView1.Rows[0];
this
.radGridView1.CurrentColumn =
this
.radGridView1.Columns[1];
this
.radGridView1.BeginEdit();
}
I hope this helps. Please let me know if you need further assistance.
Regards,
Hristo
Progress Telerik
Thank You Hristo :) .It works correctly.
Regards
ABDUL HAFEEL
Hi ,
I need to implement the row move up and down in RadGridView using RadButtons in WinForms.
Regards
ABDUL HAFEEL
Thank you for writing back.
I would like to first point that we try to keep our threads focused on a single topic. In the future please consider posting your other questions separately.
As to your actual question you can use the IsSelected and IsCurrent properties to select the next or previous rows: http://docs.telerik.com/devtools/winforms/gridview/rows/selected-rows-and-current-row.
If you need to move the entire row up or down you can use my code snippet below:
private
void
btnDown_Click(
object
sender, EventArgs e)
{
this
.MoveRow(
true
);
}
private
void
btnUp_Click(
object
sender, EventArgs e)
{
this
.MoveRow(
false
);
}
private
void
MoveRow(
bool
forward)
{
BaseGridNavigator navigator =
this
.radGridView1.GridNavigator
as
BaseGridNavigator;
var oldCurrent =
this
.radGridView1.CurrentRow;
if
(forward)
{
navigator.SelectNextRow(1);
}
else
{
navigator.SelectPreviousRow(1);
}
var newCurrent =
this
.radGridView1.CurrentRow;
if
(newCurrent !=
null
&& newCurrent.Index > -1)
{
for
(
int
i = 0; i < oldCurrent.Cells.Count; i++)
{
object
oldValue = oldCurrent.Cells[i].Value;
object
newValue = newCurrent.Cells[i].Value;
newCurrent.Cells[i].Value = oldValue;
oldCurrent.Cells[i].Value = newValue;
}
}
}
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo
Progress Telerik