Export (0) Print
Expand All
Expand Minimize

Text Property (ActiveX Controls)

Visual Studio .NET 2003

Returns or sets the text contained in an object.

Syntax

object.Text [= string]

The Text property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
string A string expression specifying the text appearing in the object.

Example

This example populates a TreeView control with the titles of files in a ListBox control. When an item in the TreeView control is clicked, the Text property is displayed in a Label on the form. To try the example, place TreeView, Label, and ListBox controls on a form and paste the code into the form's Declarations section. Run the example and click on any item to see its Text property.

Private Sub Form_Load()
   Dim nodX As Node  ' Declare an object variable for the Node.
   Dim i As Integer  ' Declare a variable for use as a counter.

   ' Add one Node to the TreeView control, and call it the first node
   Set nodX = TreeView1.Nodes.Add()
   nodX.Text = "First Node"

   'Populate the ListBox
      List1.AddItem "Node1"   ' Add each item to list.
      List1.AddItem "Node2"
      List1.AddItem "Node3"
      List1.AddItem "Node4"
      List1.AddItem "Node5"
      List1.AddItem "Node6"
      List1.AddItem "Node7"

   ' Add child nodes to the first Node object. Use the 
   ' ListBox to populate the control.
   For i = 0 To List1.ListCount - 1
      Set nodX = TreeView1.Nodes.Add(1, tvwChild)
      nodX.Text = List1.List(i)
   Next i
   Treeview1.Nodes(1).Selected = True
   nodX.EnsureVisible   ' Make sure the node is visible.
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As Node)
   ' Display the clicked Node object's Text property.
   Label1.Caption = Node.Text
End Sub

See Also

SelLength, SelStart, SelText Properties (ActiveX Controls)

Applies To: AxisTitle Object | DataPointLabel Object

Show:
© 2014 Microsoft