Solved

Need help in converting VB.NET to C#

Posted on 2006-11-27
3
226 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:mousemat24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 18020697
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)

    }
}
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 18020737
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, (int)row[MNU_ID]);
        TreeView1.Nodes.Add(node);
    }
}



private void RecursivelyAddToNode(TreeNode mymenuitem, int ParentID)

        DataView dv  = new DataView(dsTree.Tables[0]);
        dv.RowFilter = ("MNU_ParentNodeID=" + ParentID.ToString());
        foreach (DataRowView r in dv){
            TreeNode tn = new TreeNode(r["MNU_DisplayName"].ToString(), r["MNU_ID"].ToString, "", r["MNU_URL"], "");
            mymenuitem.ChildNodes.Add(tn);
            RecursivelyAddToNode(tn, (int)r["MNU_ID"]);
        }
}
0
 

Author Comment

by:mousemat24
ID: 18020802
Thanks ozymandias !!!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question