Simple Administration Application

This application uses all of the View controls on one form. It adds three Title Servers to the ServerView control named TitleServer1, TitleServer2, and TitleServer3. Information about the server currently selected in ServerView, is dynamically displayed in the TitleView, ClientView, and TraceView controls.

Form Layout

From the Visual Basic toolbox, place and size the ServerView, ClientView, TitleView and TraceView controls onto a form. Your form should look similar to the following:

Initializing the Controls

Add the following code to the Form_Load event to add the Title Servers to the ServerView control and set the other controls to display data about the first server in the list. Save the name of the first server in the list so you can check to see when it changes.

Dim strSelectedServer As String

Private Sub Form_Load()
 ' Add servers to ServerView tree
 ServerView1.AddServer ("TitleServer1")
 ServerView1.AddServer ("TitleServer2")
 ServerView1.AddServer ("TitleServer3")

 ' Save the default server name
 strSelectedServer = "TitleServer1"

 ' Set other view controls to default to 1st server
 ClientView1.SetServer (strSelectedServer)
 TitleView1.SetServer (strSelectedServer)
 TraceView1.SetServer (strSelectedServer)
 
End Sub
Selecting a New Server

Each time a new selection is made in the ServerView control, an OnSelectionChange event is triggered. This event can be used to change the data displayed in the other controls if a different server is selected. The following code uses the server name we saved in the FORM_LOAD procedure to determine if the server has changed.

Private Sub ServerView1_OnSelectionChanged(ByVal selection As Long, ByVal infotype As NSTAdminCtl.BaseInfoType)

Dim strNewServer As String ' New server selected 
Dim objServer As Object ' Temp object

' 
Set objServer = ServerView1.GetItemObject
strNewServer = objServer.Name

' If the server name has changed,
' set other view controls to new server.
If strNewServer <> strSelectedServer Then
   strSelectedServer = strNewServer
   ClientView1.SetServer (strSelectedServer)
   TitleView1.SetServer (strSelectedServer)
   TraceView1.SetServer (strSelectedServer)
End If

End Sub
Running the Application

Change the name values being passed in to the AddServer method to valid Title servers. If you connect successfully, your application should look something like this:

Tip:   You can place each control on a tab of a tabbed dialog control, such as the Microsoft® Tabbed Dialog Control.

© 1996-1998 Microsoft Corporation. All rights reserved.