Back to Devexpress

DiagramNodeEventArgs Class

aspnet-devexpress-dot-web-dot-aspxdiagram-5596495a.md

latest3.2 KB
Original Source

DiagramNodeEventArgs Class

Provides data for the NodeDataBound event.

Namespace : DevExpress.Web.ASPxDiagram

Assembly : DevExpress.Web.ASPxDiagram.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class DiagramNodeEventArgs :
    EventArgs
vb
Public Class DiagramNodeEventArgs
    Inherits EventArgs

DiagramNodeEventArgs is the data class for the following events:

Remarks

aspx
<dx:ASPxDiagram ID="Diagram" runat="server" Width="100%" Height="600px"
    NodeDataSourceID="DepartmentDemoDataSource" OnNodeDataBound="Diagram_NodeDataBound" >
    <Mappings>
        <Node Key="ID" ParentKey="ParentID" Text="DepartmentName" />
    </Mappings>
    <SettingsToolbox>
        <Groups>
            <dx:DiagramToolboxGroup CustomCategoryName="Departments" DisplayMode="Texts" />
        </Groups>
    </SettingsToolbox>
</dx:ASPxDiagram>
csharp
protected void Page_Load(object sender, EventArgs e) {
    if(!IsPostBack) {
        Diagram.CustomShapes.AddRange(GetDepartmentShapes());
    }
}
static IEnumerable<DiagramCustomShape> GetDepartmentShapes() {
    return DepartmentDataProvider.GetDepartments().Select(d =>
        new DiagramCustomShape {
            Category = "Departments",
            DefaultText = d.DepartmentName,
            Type = "dep" + d.ID,
            BaseType = DiagramShapeType.Rectangle,
        }
    );
}
protected void Diagram_NodeDataBound(object sender, DiagramNodeEventArgs e) {
    e.Node.Type = "dep" + e.Node.Key;
}
vb
Class SurroundingClass
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            Diagram.CustomShapes.AddRange(GetDepartmentShapes())
        End If
    End Sub

    Private Shared Function GetDepartmentShapes() As IEnumerable(Of DiagramCustomShape)
        Return DepartmentDataProvider.GetDepartments().[Select](Function(d) New DiagramCustomShape With {
            .Category = "Departments",
            .DefaultText = d.DepartmentName,
            .Type = "dep" & d.ID,
            .BaseType = DiagramShapeType.Rectangle
        })
    End Function

    Protected Sub Diagram_NodeDataBound(ByVal sender As Object, ByVal e As DiagramNodeEventArgs)
        e.Node.Type = "dep" & e.Node.Key
    End Sub
End Class

Inheritance

Object EventArgs DiagramNodeEventArgs

See Also

DiagramNodeEventArgs Members

DevExpress.Web.ASPxDiagram Namespace