260 likes | 896 Views
Treeview and Listview Controls. Tonga Institute of Higher Education. Treeview Control. Parent of Students And Staff Nodes. There are many controls you can use to create professional software applications Form Label LinkLabel TextBox Etc.
E N D
Treeview and Listview Controls Tonga Institute of Higher Education
Treeview Control Parent of Students And Staff Nodes • There are many controls you can use to create professional software applications • Form • Label • LinkLabel • TextBox • Etc. • A treeview control is useful as showing data in a tree • Use tvw as a prefix treeviews • Example: tvwMinistryOfEducation Nodes Roots Children of Tutors Node
BackColor Determines the background color of the form BorderStyle Determines the style of the border None FixedSingle Fixed3D CheckBoxes Determines whether a checkbox is displayed for each node Enabled Determines whether the user can use the control Font Determines the font of the text displayed FullRowSelect Determines whether a full row can be selected There is a bug where it won’t work if ShowLines and ShowPlusMinus are true HideSelection Removes the highlight from the selected node when control doesn’t have focus Location Determines the current location of the form on the screen Name Determines the name used to reference this form in your code Nodes Determines the nodes in the treeview Scrollable Determines whether scroll bars should automatically appear if the form’s contents use more space than the size of the form ShowLines Determines whether lines are displayed ShowPlusMinus Determines whether plus/minus is displayed ShowRootLines Determines whether root lines are displayed Size Determines the current size of the form Sorted Determines whether the nodes are sorted TabIndex Determines the index of the Tab order that this control will occupy TabStop Determines whether the tab order will stop at this control Visible Determines the visibility of the control Anchor Anchors the control to an edge of a container so a side of the control grows gracefully Dock Docks the control in a location in a container so the control grows gracefully Treeview Properties
Adding Nodes through the Properties Window • Click on Nodes in the properties window. A button with 3 periods is displayed • Click on the button with 3 periods • The Treenode Editor window is displayed
Demonstration Changing Nodes through the Treeview Editor Window
TreeNode Object • Each node is a TreeNode object • The TreeNode object has many properties and methods • Checked • Collapse • Expand • IsSelected • IsVisible • NextNode • Parent • PrevNode • Remove • Text • And others
TreeNodeCollection Object • A collection of TreeNodes is a TreeNodeCollection object • The TreeNodeCollection object has many properties and methods • Clear • Remove • And Others
Selecting a Node • To select a node, we must find the location of the node tvwMain.SelectedNode = tvwMain.Nodes(0).Nodes(1) Nodes represents a TreeNodeCollection Each level uses Nodes Node Index starts from 0 Property allows selected node to be changed The location of the node
Controlling Treeviews with Code TreeNodeCollection object controls the collection of nodes • Adding Nodes tvwMinistryOfEducation.Nodes.Add("New Root") • Deleting Nodes tvwMinistryOfEducation.Nodes(0).Remove() Text inside of new node Control name Method to add node Finds a TreeNode object Control name Method to Delete node
Demonstration Working with Treeviews through Code
ListView Control • Listviews allow users to display data in a table • The properties are covered in IT142
ListViewItem Object • Each row is a ListViewItem object • The ListViewItem object has many properties and methods • Remove • Selected • And others • To access a ListViewItem, find the location of the ListViewItem ListViewItem
ListViewItemCollection Object • A collection of ListViewItems is a ListViewItemCollection object • The ListViewItemCollection object has many properties and methods • Add • Clear • And Others
Highlighting ListViewItems with Code lvwActivity2.Items(1).Selected = True Property to Select item The location of the ListViewItem
Adding ListViewItems with Code We must add strings to subitems
Demonstration Working with ListViews through Code