Back to Devexpress

DxHtmlPainterContext.OnMouseMove(MouseEventArgs, Object) Method

windowsforms-devexpress-dot-utils-dot-html-dot-dxhtmlpaintercontext-dot-onmousemove-x28-system-dot-windows-dot-forms-dot-mouseeventargs-system-dot-object-x29.md

latest4.1 KB
Original Source

DxHtmlPainterContext.OnMouseMove(MouseEventArgs, Object) Method

Transfers the MouseMove mouse event to the target HTML element. This allows the element to change its visual state from “normal” to “hovered”.

Namespace : DevExpress.Utils.Html

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public void OnMouseMove(
    MouseEventArgs e,
    object interactivityKey = null
)
vb
Public Sub OnMouseMove(
    e As MouseEventArgs,
    interactivityKey As Object = Nothing
)

Parameters

NameTypeDescription
eMouseEventArgs

The EventArgs object utilized by the origin MouseMove event (the MouseMove event of the parent control).

|

Optional Parameters

NameTypeDefaultDescription
interactivityKeyObjectnull

The ID that allows you to identify the specific instance of a custom-drawn template.

|

Remarks

The code below illustrates how to paint instances of the same HTML template inside Data Grid row preview areas, and assign unique IDs to all of these instances. The control’s MouseMove event is handled to identify the specific template instance of a template, and transmit this mouse event to this instance.

csharp
DxHtmlPainterContext ctx = new DxHtmlPainterContext();

gridView.CustomDrawRowPreview += (s, e) => {
    // Use a data source row index as a template instance ID
    int index = (s as GridView).GetDataSourceRowIndex(e.RowHandle);
    e.DrawHtml(htmlTemplate, ctx, (args) => args.InteractivityKey = index);
    e.Handled = true;
};

gridView.MouseMove += (s, e) => {
    GridView view = s as GridView;
    GridHitInfo hitInfo = view.CalcHitInfo(e.Location);
    if(hitInfo.RowHandle >= 0) {
        int index = view.GetDataSourceRowIndex(hitInfo.RowHandle);
        // Use the same interaction key value to find the correct template
        ctx.OnMouseMove(e, index);
        view.GridControl.Cursor = ctx.GetCursor(e.Location, index);
        view.InvalidateRow(hitInfo.RowHandle);
    }
};
vb
Dim ctx As New DxHtmlPainterContext()

AddHandler gridView.CustomDrawRowPreview, Sub(s, e)
    ' Use a data source row index as a template instance ID
    Dim index As Integer = (TryCast(s, GridView)).GetDataSourceRowIndex(e.RowHandle)
    e.DrawHtml(htmlTemplate, ctx, Sub(args) args.InteractivityKey = index)
    e.Handled = True
End Sub

AddHandler gridView.MouseMove, Sub(s, e)
    Dim view As GridView = TryCast(s, GridView)
    Dim hitInfo As GridHitInfo = view.CalcHitInfo(e.Location)
    If hitInfo.RowHandle >= 0 Then
        Dim index As Integer = view.GetDataSourceRowIndex(hitInfo.RowHandle)
        ' Use the same interaction key value to find the correct template
        ctx.OnMouseMove(e, index)
        view.GridControl.Cursor = ctx.GetCursor(e.Location, index)
        view.InvalidateRow(hitInfo.RowHandle)
    End If
End Sub

See this article to learn more about transmitting mouse events from parent controls to HTML template instances: Custom Draw Templates.

See Also

DxHtmlPainterContext Class

DxHtmlPainterContext Members

DevExpress.Utils.Html Namespace