August 11th, 2011, 10:05 PM
My First Browser Tree Program in VB.NET
My First Browser Tree Program in VB.NET
Within the first few weeks of programming in VB.NET, your user interface should become a bit more sophisticated. The blog VBNETFOREST at WordPress (http://vbnetforest.wordpress.com) offers the source code as well as step by step in a single lesson to help you learn how you can turn your form into a browser tree so that you can display information in a structure of limitless complexity.As advertised by its slogan, VB.NET for the rest of us, this blog does not put you through an agony of extraneous verbiage. With two procedures plus the provided source code, you can in few minutes turn a simple form into a sophisticated browser tree, which is a window divided into two panels: a collapsible tree view on the left and a browser box on the right. When done coding your user can click on a node to show a different web page on the right. The short link to this lesson is http://wp.me/p1ISdW-5r (case sensitive). Or you can find it on http://vbnetforest.wordpress.com/lessons
Procedure 1 – Getting Started
A browser tree is a window divided into two panels. On the left is a collapsible tree view and on the right is a browser box. Click on a node to show a different web page on the right. To get started with the programming of a browser tree in VB.NET, do the following steps:
1. Start Visual Studio and select the menu File » New Project …
2. Select project type VB Windows and template WinFormApp.
3. Set the application name as vs2008winAppBrowserTree or so.
4. Select File » Save All
5. Save the project and create the solution vs2008browserForest
6. Select the menu View » Toolbox
7. Drop down the tool collection Menus & Toolbars
8. Drag the StatusStrip over and drop it on Form1.
9. On the StatusStrip dropdown, select ToolStripStatusLabel1.
10. Drag the MenuStrip over and drop it on Form1.
11. Do the next two steps as instructed: using the exact spelling.
12. Add &File and &Close menu items.
13. Add &Help and &About menu items.
14. Drop down the tool collection Components.
15. Drag the Timer over and drop it on Form1.
16. Press F7 to View » Code
17. Replace the default code with the source code as shown below.
18. Run the program and wait 5 seconds to see the status message disappears by itself.
19. If all works as expected, follow the steps in the next procedure.
01 Public Class Form1
03 Private Form1_MouseMove_StartTime As Date
05 Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
07 End Sub
09 Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
10 With My.Application.Info
11 Dim s As String = .ProductName & " version " & .Version.ToString
12 MsgBox("Welcome to " & s, MsgBoxStyle.Information, .ProductName)
13 End With
14 End Sub
16 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
17 With My.Application.Info
18 Me.Text = .ProductName
19 Dim s As String = .ProductName & " version " & .Version.ToString
20 ToolStripStatusLabel1.Text = s
21 End With
22 Timer1.Enabled = True
23 End Sub
25 Private Sub ToolStripStatusLabel1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel1.TextChanged
26 Form1_MouseMove_StartTime = Now
27 End Sub
29 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
30 If ToolStripStatusLabel1.Text <> "" Then
31 If DateDiff(DateInterval.Second, Form1_MouseMove_StartTime, Now) > 5 Then
32 ToolStripStatusLabel1.Text = ""
33 End If
34 End If
35 End Sub
37 End Class
Procedure 2 – Add Tree View and Browser Box
1. Open the project you created in the procedure prior to this.
2. Drop down the tool collection Containers.
3. Drag the SplitContainer control over and drop it on Form1.
4. Set its border style to be fixed single.
5. You should see Panel1 and Panel2 on Form1.
6. Drop down the tool collection Common Controls.
7. Drag the TreeView control over and drop it on Panel1.
8. Click on the visible right arrow and dock the control.
9. Drag the WebBrowser control over and drop it on Panel2.
10. On the right of File and Help click on the blank spot.
11. Do the next step as instructed: using the exact spelling.
12. Type in and create new menu items: &View and &Tree
13. Drag the View menu over and drop it in between File and Help.
14. You should now see only three menu items on the menu bar.
15. You should see only a single item under each of the three menus.
16. Copy the source code as shown right below this procedure.
17. Press F7 to view the source code.
18. Insert the new code right above the End Class statement at the bottom.
19. Run and test the new feature View » Tree
20. If all works as expected, follow the steps in the next procedure.
01 Public Function ToggleTreeView()
02 If TreeToolStripMenuItem.Checked Then
03 With SplitContainer1
04 .Panel1MinSize = 0
05 .Panel2MinSize = 0
06 .SplitterDistance = 0
07 End With
08 TreeToolStripMenuItem.Checked = False
10 With SplitContainer1
11 .Panel1MinSize = 25
12 .Panel2MinSize = 25
13 .SplitterDistance = .Width / 3
14 End With
15 TreeToolStripMenuItem.Checked = True
16 End If
17 ToggleTreeView = TreeToolStripMenuItem.Checked
18 End Function
19 Private Sub TreeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TreeToolStripMenuItem.Click
21 End Sub
August 12th, 2011, 03:38 AM
Re: My First Browser Tree Program in VB.NET
This is the C++ section, not VB. Also, what is the meaning of this post ?
Tags for this Thread
Click Here to Expand Forum to Full Width