Link to home
Start Free TrialLog in
Avatar of mousemat24
mousemat24

asked on

Need help in converting VB.NET to C#

Can someone please help me convert this VB.NET to C#

Thanks

            Dim a As Integer
            With dsTree.Tables(0)
                For a = 0 To .Rows.Count - 1
                    If .Rows(a).Item("MNU_ParentNodeID") = 0 Then
                        Dim tn As New TreeNode(.Rows(a).Item("MNU_DisplayName"), .Rows(a).Item("MNU_ID").ToString, "", .Rows(a).Item("MNU_URL"), "")
                        RecursivelyAddToNode(tn, .Rows(a).Item("MNU_ID"))
                        TreeView1.Nodes.Add(tn)

                    End If
                Next
            End With





Private Sub RecursivelyAddToNode(ByVal mymenuitem As TreeNode, ByVal ParentID As Integer)

        Dim dv As New DataView(dsTree.Tables(0))
        dv.RowFilter = ("MNU_ParentNodeID=" & ParentID.ToString)
        Dim r As DataRowView
        For Each r In dv
            Dim tn As New TreeNode(r.Item("MNU_DisplayName"), r.Item("MNU_ID").ToString, "", r.Item("MNU_URL"), "")
            mymenuitem.ChildNodes.Add(tn)
            RecursivelyAddToNode(tn, r.Item("MNU_ID"))
        Next

    End Sub




Many thanks
Avatar of ozymandias
ozymandias
Flag of United Kingdom of Great Britain and Northern Ireland image

First bit is something like this :

foreach (dataRow row in dsTree.Tables[0].Rows){
    if ((int)row["MNU_ParentNodeID"] == 0){
        TreeNode node = new TreeNode(row["MNU_DisplayName"].ToString(), row["MNU_ID"].ToString(), row["MNU_URL"].ToString(), "");
        RecursivelyAddToNode(node, row[MNU_ID])
        TreeView1.Nodes.Add(node)

    }
}
ASKER CERTIFIED SOLUTION
Avatar of ozymandias
ozymandias
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mousemat24
mousemat24

ASKER

Thanks ozymandias !!!