Hello,
I have standard control drag and drop in my app, so I have .net DragEnter, DragDrop, DragOver, etc. handlers for the RadGridView in my form. Of course, grid doesn't react properly on mouse activity over it. In my DragOver handler I want to set row under the cursor to hovered state. I found GridTableElement.HoveredRow property, but it is internal. Is there a way to programmatically make grid to set a row into howered state?
3 Answers, 1 is accepted
Thank you for writing.
In order to highlight the target cell, you can handle the RadGridView.DragOver, get the cell element under the mouse and customize its look:
GridCellElement lastCell =
null
;
private
void
radGridView1_DragOver(
object
sender, DragEventArgs e)
{
if
(lastCell !=
null
)
{
lastCell.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
lastCell.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
lastCell.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
}
Point p =
this
.radGridView1.PointToClient(
new
Point(e.X,e.Y));
lastCell =
this
.radGridView1.ElementTree.GetElementAtPoint(p)
as
GridCellElement ;
if
(lastCell !=
null
)
{
lastCell.DrawFill =
true
;
lastCell.BackColor = Color.LightCyan;
lastCell.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Hello Dess,
Well, this is just a workaround, because the tracking will not be the same as the normal one. I need to highlight full row, so I changed your example from cells to rows. But row header is not highlighted and there is no triangle icon on it. In case the row is selected, changing all these properties messed up the things, because current cell remains selected but the rest of the row becomes just highlighted.
But as you've provided a workaround, that means there is no defined way to do that I need. So I guess I have to live with this approach. But I would ask you to think about making GridTableElement.HoveredRow a public property (or something similar). :)
Thank you
Thank you for writing back.
I am glad that the suggested solution is applicable for your case. Note that changing the color for the hovered element in the DragOver event is a standard approach for achieving such a requirement. There are a lot of threads related to this topic in stackOverflow. Here is one of them: http://stackoverflow.com/questions/8146705/how-to-highlight-target-node-while-dragging
As to the question about the GridTableElement.HoveredRow property, note that it is designed for internal usage as it is responsible for the hot tracking state of a row element which is used in the themes.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress