User:Foxall/08

Ka Wiktionary

Hour 8. Advanced Controls[wax ka badal]

The standard controls presented in the previous hour enable you to build many types of functional forms. However, to create truly robust and interactive applications, you've got to use the more advanced controls. As a Windows user, you've encountered many of these controls, such as the Tab control, which presents data on tabs, and the Tree View control, which displays hierarchical lists such as the one in Explorer. In this hour, you'll learn about these advanced controls and learn how to use them to make professional interfaces like those you're accustomed to seeing in commercial products.

The highlights of this hour include the following:

  • [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch08lev1sec1.htm#ch08lev1sec1 Creating timers]
  • [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch08lev1sec2.htm#ch08lev1sec2 Creating tabbed dialog boxes]
  • [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch08lev1sec3.htm#ch08lev1sec3 Storing pictures in an Image List]
  • [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch08lev1sec4.htm#ch08lev1sec4 Building enhanced lists using the List View control]
  • [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch08lev1sec5.htm#ch08lev1sec5 Creating hierarchical lists with the Tree View control]
graphics/bookpencil.gif In many of the examples in this hour, I show you how to add items to collections at design time. Keep in mind that almost everything you can do at design time can also be accomplished with C# code at runtime.

Creating Timers[wax ka badal]

One thing that all the controls you used in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch07.htm#ch07 Hour 7], "Working with Traditional Controls," have in common is that the user can interact with them. However, not all controls have this capability�or restriction, depending on how you look at it. Some controls are designed for use only by the developer. One such control is the Open File Dialog control you used in your Picture Viewer application in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch01.htm#ch01 Hour 1], "A C# Programming Tour." Another control that is invisible at runtime is the Timer control. The Timer control's sole purpose is to trigger an event at a specified interval of time.

Create a new Windows Application titled Timer Example. Change the name of the default form to fclsTimerExample and then set its Text property to Timer Example. Next, be sure to set the Main() entry point of the project to fclsTimerExample or the project won't run. Add a new Timer control to your form by double-clicking the Timer item in the toolbox. Because the Timer control is invisible at runtime, it's added to the gray area at the bottom of the screen rather than placed on the form (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig01 Figure 8.1]). Set the properties of the Timer control as follows:

Figure 8.1. Invisible-at-runtime controls are shown at the bottom of the designer, not on the form.

graphics/08fig01.jpg

Property Value
Name tmrClock
Enabled True
Interval 1000

You probably noticed that there are very few properties for the Timer control, compared to the other controls with which you've worked. The key property of the Timer control is the Interval property. The Interval property determines how often the Timer control fires its Tick event. The Interval is specified in milliseconds, so a setting of 1,000 is equal to 1 second. The best way to understand how the timer works is to use it. Using the Timer and a Label control, you're now going to create a simple clock. The way the clock will work is that the timer will fire its Tick event once every second (because you'll set the Interval = 1000 milliseconds), and within the Tick event, the label's Text property will be updated with the current system time.

Add a new label to the form and set its properties as follows:

Property Value
Name lblClock
BorderStyle FixedSingle
Location 96,120
Size 100,23
Text (make blank)
TextAlign MiddleCenter

Next, double-click the Timer control to access its Tick event. When a timer is first enabled, it starts counting, in milliseconds, from 0. When the amount of time specified in the Interval property passes, the Tick event fires and the timer starts counting from 0 again. This continues until the timer is disabled (that is, when its Enabled property is set to False). Because you've set the Enabled property of the timer to True at design time, it will start counting as soon as the form on which it is placed is loaded. Enter the following statement in the Tick event:

DateTime dtCurrentTime = DateTime.Now;
lblClock.Text = dtCurrentTime.ToLongTimeString();

The .NET Framework provides date/time functionality in the System namespace. The Now property of the DateTime class returns the current time. Using the ToLongTimeString method returns a string with a time format of hh:mm:ss. Using this class, property, and method, we set the Text property of the label to the current time of day, and it does this once a second. Press F5 to run the project now and you'll see the Label control acting as a clock, updating the time every second (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig02 Figure 8.2]).

Stop the running project now and save your work. Timers are powerful, but you must take care not to overuse them. For a timer to work, Windows must be aware of the timer and must constantly compare the current internal clock to the interval of the timer. It does all this so that it can notify the timer at the appropriate time to execute its Tick event. In other words, timers take system resources. This isn't a problem for an application that uses a few timers, but I wouldn't overload an application with a dozen timers unless I had no other choice.

Creating Tabbed Dialog Boxes 

Windows 95 was the first version of Windows to introduce a tabbed interface. Since then, tabs have been unanimously adopted as a primary interface element. Tabs provide two primary benefits: the logical grouping of controls and the reduction of required screen space. Although tabs may look complicated, they are, in fact, extremely easy to build and use.

Create a new Windows Application named Tabs Example. Change the name of the default form to reference fclsTabs instead of Form1, set its Text property to Tabs Example, and modify the Main() entry point to fclsTabs. Next, add a new Tab control to your form by double-clicking the TabControl item in the toolbox. At first, the new control looks more like a panel than a set of tabs because it has no tabs. Set the Tab control's properties as follows:

Property Value
Name tabMyTabs
Location 8,16
Size 272,208

The tabs on a Tab control are part of the control's TabPages collection. Click the TabPages property of the Tab control in the Properties window and then click the small button that appears. C# then shows the TabPage Collection Editor. As you can see, your Tab control has no tabs. Click Add now to create a new tab (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig03 Figure 8.3]).

Figure 8.3. New Tab controls have no tabs; you must create them.

graphics/08fig03.jpg

Each tab in the collection is called a page. C# names each new page with TabPageX, in which X is a unique number. It's usually not necessary to change the name of a page, but you can if you choose. Each page has a number of properties, but the property you'll be concerned with most is the Text property because the value in the Text property is the text the user will see on the tab. Change the Text property of your tab page to Contacts, and then click Add to create a second page. Change the Text property of the second page to Appointments and click OK to close the dialog box. Your Tab control now has two tabs (pages).

graphics/bulb.gif A shortcut to adding or removing a tab is to use the shortcuts provided in the description pane at the bottom of the Properties window.

Each page on a Tab control acts as a container, much like the Panel and Group Box controls. This is why you can't drag the Tab control by clicking in the middle of it; to drag a container control, you have to click and drag the dotted border around the control. Add a text box to the first tab now by dragging the TextBox item from the toolbox and dropping in on the tab page. After it's on the page, drag it to approximately the center of the page. Next, click the Appointments tab, the same as if you were a user switching tabs. As you can see, the Appointments tab comes to the front, and the text box is no longer visible. C# has hidden the first page and shown you the second. Drag a check box from the toolbox and drop it on the tab page, and then click Contacts once more. Again, C# handles the details of showing and hiding the tab pages; you no longer see the check box, but you do see the text box (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig04 Figure 8.4]).

Figure 8.4. The Tab control makes it easy to create a tabbed interface.

graphics/08fig04.jpg

By understanding two simple programming elements, you'll be able to do 99% of what you need to with the Tab control. The first is that you will, at times, need to know which tab is selected. The SelectedIndex property of the control (not of the TabPages collection) sets and returns the index of the currently selected tab�0 for the first tab, 1 for the second, and so forth. The second thing you need to know is how to tell when the user switches tabs. The Tab control has a SelectedIndexChanged event, which fires whenever the selected tab is changed. In this event, you can check the value of SelectedIndex to determine the tab that has been selected. The only tricky part here is that each tab page has its own set of events, so to get to the events of the Tab control itself, you'll have to use the techniques discussed in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch04.htm#ch04 Hour 4], "Understanding Events."

Storing Pictures in an Image List 

Many of the controls I'll be discussing in this hour support the capability to attach pictures to different types of items. For instance, the Tree View control, which is used in Explorer for navigating folders, displays images next to each folder node. Not all these pictures are the same; the control uses specific pictures to denote information about each node. It would have been possible for Microsoft to make each control store its images internally, but that would be highly inefficient because it wouldn't allow controls to share the same pictures; you'd have to store the pictures in each control that needed them. Instead, Microsoft created a control dedicated to storing pictures and serving them to other controls: the Image List.

Create a new Windows Application named Lists and Trees. Change the name of the default form to fclsListsAndTrees, set its Text property to Lists and Trees Example, and set the entry point of the project to reference fclsListsAndTrees instead of Form1. Next, add a new Image List control by double-clicking the ImageList item in the toolbox. Like the timer, the Image List is an invisible-at-runtime control, so it appears below the form. Change the name of the Image List to imgMyImages.

The sole purpose of an Image List control is to store pictures and make them available to other controls. The pictures of an Image List are stored in the Images collection of the control. Click the Images property of the control in the Properties window and then click the small button that appears. C# then displays the Image Collection Editor, which is similar to other editors you've used in this hour. Click Add to display the Open dialog box and use this dialog box to locate and select a 16x16 pixel bitmap. If you don't have a 16x16 pixel bitmap, you can create one using Microsoft Paint, or you can download samples I've provided at http://www.samspublishing.com/detail_sams.cfm?item=0672322870. After you've added an image, click OK to close the Image Collection Editor.

Take a look at the ImageSize property of the Image control. It should read 16,16. If it doesn't, the bitmap you selected is not 16x16 pixels; this property sets itself to the dimensions of the first picture added to the Image List.

You can't always rely on the background where a picture will be displayed to be white�or any other color for that matter. Because of this, the Image List has a TransparentColor property. By default, this is set to Transparent, which essentially means that no color in the picture is transparent (if the pictures in the Image List are icons, rather than bitmaps, the transparent portion of the icons will remain transparent). If you designate a specific color for the TransparentColor property, when a picture is served from the Image List to another control, all occurrences of the specified color will appear transparent�the background will show through. This gives you the power to create pictures that can be served to controls without concern about the color on which the picture will appear.

That's all there is to adding images to an Image List. The power of the Image List resides in its capability to be linked to by other controls that can access the pictures it stores.

Building Enhanced Lists Using the List View 

The List View control is like a list box on steroids�and then some. The List View can be used to create simple lists, multicolumn grids, and icon trays. The right pane in Explorer is a List View. (You may not know it, but you can change the appearance of the List View in Explorer by right-clicking it and using the View submenu of the context menu that appears.) The primary options you have available for changing the appearance of your List Views are Large Icons, Small Icons, List, and Details. These correspond exactly to the display options available for a List View by way of its View property. You're going to create a List View with a few items on it and experiment with the different views�including showing a picture for the items.

graphics/bulb.gif I can only scratch the surface of this great control here. After you've learned the basics in this hour, I highly recommend that you spend some time with the control, the help text, and whatever additional material you can find. I use the List View all the time; it's a very powerful tool to have in your arsenal because displaying lists is so common.

Add a List View to your form now by double-clicking the ListView item in the toolbox. Set the properties of the List View as follows:

Property Value
Name lvwMyListView
Location 8,8
Size 275,97
SmallImageList imgMyImages
View Details

As you can see, you can attach an Image List to a control via the Properties window (or with code). Not all controls support the Image List, but those that do make it as simple as setting a property to link to an Image List. The List View actually allows linking to two Image Lists: one for large icons (32x32 pixels) and one for small images. In this example, you're going to use only small pictures. If you wanted to use the large format, you could hook up a second Image List containing larger images to the List View's LargeImageList control.

 Creating Columns 

When you changed the View property to Details, an empty header was placed at the top of the control. The contents of this header are determined by the columns defined in the Columns collection.

Select the Columns property on the Properties window and click the small button that appears. C# then displays the ColumnHeader Collection Editor window. Click Add to create a new header and change its Text to Name and its Width to 120. Click Add once more to create a second column and change its Text to State. Click OK to save your column settings and close the window. Your list view should now have two named columns (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig05 Figure 8.5]).

Figure 8.5. List Views enable you to present multicolumn lists.

graphics/08fig05.jpg

 Adding List Items 

You're now going to add two items to the list view.

  1. Click the Items property in the Properties window and then click the small button that appears, which displays the ListViewItem Collection Editor dialog box.
  2. Click Add to create a new item, and change the item's Text to James Foxall.
  3. Next, open the drop-down list for the ImageIndex property. Notice how the list contains the picture in the linked Image List control (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig06 Figure 8.6]). Select the image.
Figure 8.6. Pictures from a linked Image List are readily available to the control.

graphics/08fig06.jpg

  1. The Text property of an item determines the text displayed for the item in the List View. If the View property is set to Details and multiple columns have been defined, the value of the Text property appears in the first column. Subsequent column values are determined by the SubItems collection.
  2. Click the SubItems property and then click the small button that appears, which displays the ListViewSubItem Collection Editor. The item that appears in the list refers to the text of the item itself, which you don't want to change.
  3. Click Add to create a new sub item and change its text to Nebraska.
  4. Click OK to return to the ListViewItem Collection Editor.
  5. Click the Add button to create another item. This time, change the Text property to your name and use the techniques you just learned to add a sub item. For the Text property of the sub item, enter your state of residence.
  6. When you're finished, click OK to close the ListViewItem Collection Editor. Your List View should now contain two list items (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig07 Figure 8.7]).
Figure 8.7. List views offer much more functionality than a standard list box.

graphics/08fig07.jpg

  1. Next, experiment with the View property of the List View control to see how the various settings affect the appearance of the control. The Large Icons setting doesn't display an icon, because you didn't link an Image List control to the LargeImageList property of the List View.
  2. Press F5 to run the project and try selecting your name by clicking your state. You can't. The default behavior of the List View is only to consider the clicking of the first column as selecting an item.
  3. Stop the project and change the FullRowSelect property to True; then run the project once more.
  4. Click your state again, and this time your name becomes selected (actually, the entire row becomes selected). Personally, I prefer to set up all my List Views with FullRowSelect set to True, but this is just a personal preference. Stop the project now and save your work.
Manipulating a List View Using Code 

You've just learned the basics of working with a List View control. Although you performed all the steps in Design view, you'll probably manipulate your list items using code because you won't necessarily know ahead of time what to display in the list, so I'll show you how.

 Adding List Items Using Code 

Adding an item using code is very simple�if the item you are adding is simple. To add an item to your list view, you use the Add method of the Items collection, like this:

lstMyListView.Items.Add("Mark Haro");

If the item is to have a picture, you can specify the index of the picture as a second parameter, like this:

lstMyListView.Items.Add("Luis Haro",0);

If the item has sub items, things get more complicated. The Add method allows you only to specify the text and image index. To access the additional properties of a list item, you need to get a reference to the item in code. Remember that new items have only one sub item; you have to create additional items. The Add method of the Items collection returns a reference to the newly added item. Knowing this, you can create a new variable to hold a reference to the item, create the item, and manipulate anything you choose to about the item using the variable (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch12.htm#ch12 Hour 12], "Using Constants, Data Types, Variables, and Arrays," for information on using variables). The following code creates a new item and appends a sub item to its SubItems collection:

ListViewItem objListItem;
objListItem = lstMyListView.Items.Add("Yvette Webster", 0);
objListItem.SubItems.Add("Tennessee");

Determining the Selected Item in Code

The List View control has a collection that contains a reference to each selected item in the control: the SelectedItems collection. If the MultiSelect property of the List View is set to True, as it is by default, the user can select multiple items by holding down the Ctrl or Shift keys when clicking items. This is why the List View supports a SelectedItems collection rather than a SelectedItem property. To gather information about a selected item, you refer to it by its index. For example, to print the text of the first selected item (or the only selected item if just one is selected), you could use code like this:

if (lstMyListView.SelectedItems.Count > 0)
System.Diagnostics.Debug.WriteLine(lstMyListView.SelectedItems[0].Text);

The reason you check the Count property of the SelectedItems collection is that if no items are selected, you would cause a runtime error by attempting to reference element 0 in the SelectedItems collection.

 Removing List Items Using Code 

To remove a list item, use the Remove method of the Items collection. The Remove Item method accepts and expects a reference to a list item. For instance, to remove the currently selected item, you could use a statement such as

lstMyListView.Items.Remove(lstMyListView.SelectedItems[0]);

or

lstMyListView.Items.RemoveAt(0);

Again, you'd want to make sure an item is actually selected before using this statement.

 Removing All List Items 

If you're filling a List View using code, you'll probably want to clear the contents of the List View first. That way, if the code to fill the List View is called a second time, you won't create duplicate entries. To clear the contents of a List View, use the Clear method of the Items collection, like this:

lstMyListView.Items.Clear();

The List View control is an amazingly versatile tool. As a matter of fact, I rarely use the standard list box now, preferring to use the List View because of its added functionality, such as displaying an image for an item. I've barely scratched the surface here, but you now know enough to begin using this awesome tool in your own development.

>

Creating Hierarchical Lists with the Tree View

The Tree View control is used to present hierarchical data. Perhaps the most commonly used Tree View control is found in Explorer, where you can use the Tree View to navigate the folders and drives on your computer. The Tree View is perfect for displaying hierarchical data, such as a departmental display of employees. In this section, I'll teach you the basics of the Tree View control so that you can use this great interface element in your applications.

The Tree View's items are contained in a Nodes collection. To add items to the tree, you append them to the Nodes collection. As you can probably see by now, after you understand the basics of objects and collections, you can apply that knowledge to almost everything in C#. For instance, the skills you learned in working with the Items collection of the List View control are similar to the skills needed for working with the Nodes collection of the Tree View control.

Add a Tree View control to your form now by double-clicking the TreeView item in the toolbox. Set the Tree View control's properties as follows:

Property Value
Name tvwLanguages
ImageList imgMyImages
Location 8,128
Size 272,97
Adding Nodes to a Tree View 

To add a node, call the Add method of the Nodes collection. Add a new button to your form and set its properties as follows:

Property Value
Name btnAddNode
Location 8,240
Size 75,23
Text Add Node

Double-click the button to access its Click event and enter the following code:

tvwLanguages.Nodes.Add("Sam Chun");
tvwLanguages.Nodes.Add("C#");

Press F5 to run the project, and then click the button. Two nodes will appear in the tree, one for each Add method call (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig08 Figure 8.8]).

Figure 8.8. Nodes are the items that appear in a tree.

graphics/08fig08.jpg

Notice how both nodes appear at the same level in the hierarchy; neither node is a parent or child of the other. If all your nodes are going to be at the same level in the hierarchy, you should consider using a List View instead, because what you're creating is simply a list.

Stop the project and return to the button's Click event. Any given node can be both a parent to other nodes and a child of a single node. For this to work, each node has its own Nodes collection. This can get confusing, but if you realize that children nodes belong to the parent node, it starts to make sense (but it still gets confusing in practice). You're now going to create a new button that adds the same two nodes as before but makes the second node a child of the first. Create a new button and set its properties as shown:

Property Value
Name btnCreateChild
Location 96,240
Size 80,23
Text Create Child

Double-click the new button to access its Click event and add the following code:

TreeNode objNode;
objNode = tvwLanguages.Nodes.Add("Wendy Chun");
objNode.Nodes.Add("C#");

This code is similar to what you created in the List View example. The Add method of the Nodes collection returns a reference to the newly created node. Thus, this code creates a variable of type TreeNode (variables are discussed in detail in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch12.htm#ch12 Hour 12]), creates a new node whose reference is placed in the variable, and then adds a new node to the Nodes collection of the first node. To see the effect that this has, press F5 to run the project and click the new button. You'll see a single item in the list, with a plus sign to the left of it. This plus sign indicates that child nodes exist. Click the plus sign, and the node is expanded to show its children (see [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#ch08fig09 Figure 8.9]).

Figure 8.9. You can create as deep a hierarchy as you need.

graphics/08fig09.jpg

This example is a simple one�a single parent node having a single child node. However, the principles used here are the same as those used to build complex trees with dozens or hundreds of nodes.

 Removing Nodes 

Removing a node is simply a matter of calling the Remove method of the Nodes collection. The Remove method accepts and expects a valid node, so you must know which node to remove. Again, the Nodes collection works very much like the Items collection in the List View control, so the same ideas apply. For example, the currently selected node is returned in the SelectedNode property of the Tree View. So, to remove the currently selected node, you could use this statement:

tvwLanguages.Nodes.Remove(tvwLanguages.SelectedNode);

If this statement is called when no node is selected, an error would occur. In [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch12.htm#ch12 Hour 12], you'll learn all about data types and equalities, but here's a preview: If an object variable doesn't reference an object, it is equivalent to the C# keyword null. Knowing this, you could validate whether an item is selected with a little bit of logic, like this:

if (!(tvwLanguages.SelectedNode == null))
tvwLanguages.Nodes.Remove(tvwLanguages.SelectedNode);
graphics/bookpencil.gif Removing a parent node causes all its children to be removed as well.
Clearing All Nodes 

To clear all nodes in a Tree View, invoke the Clear method of the Nodes collection, like this:

tvwLanguages.Nodes.Clear();

As with the List View, I've only scratched the surface of the Tree View. Spend some time becoming familiar with the basics of the Tree View, as I've shown here, and then dig a bit deeper to discover the not-so-obvious power and flexibility of this control.

Summary 

C# includes a number of controls that go beyond the standard functionality of the traditional controls discussed in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch07.htm#ch07 Hour 7]. In this hour, I discussed the most commonly used advanced controls. You learned how to use the Timer control to trigger events at predetermined intervals. You also learned how to use the tab to create the tabbed dialog boxes with which you're so familiar.

Also in this hour, you learned how to add pictures to an Image List so that other controls can use them. The Image List makes it easy to share pictures among many controls, making it a very useful tool. Finally, I taught you the basics of the List View and Tree View controls; two controls you can use to build high-end interfaces that present structured data. The more time you spend with all these controls, the better you will become at creating great interfaces.

Q&A
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#qad1e28118 Q1:] What if I need a lot of timers, but I'm concerned about system resources?
A1: When possible, use a single timer for multiple duties. This is extremely easy when two events occur at the same interval�why bother creating a second timer? When two events occur at different intervals, you can use some decision skills along with static variables (discussed in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/ch12.htm#ch12 Hour 12]) to share Timer events.
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/08.htm#qad1e28132 Q2:] What else can I do with an Image List?
A2: You can assign a unique picture to a node in a Tree View when the node is selected. You can also display an image in the tab of a tab page in a Tab control. There are a lot of uses, and as you learn more about advanced controls, you'll see additional opportunities for using images from an Image List.
>

Workshop

The Workshop is designed to help you anticipate possible questions, review what you've learned, and get you thinking about how to put your knowledge into practice. The answers to the quiz are in [file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01.htm#app01 Appendix A],"Answers to Quizzes/Exercises."

 Quiz
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans01 1:] What increment of time is applied to the Interval property of the Timer control?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans02 2:] What collection is used to add new tabs to a Tab control?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans03 3:] What property returns the index of the currently selected tab?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans04 4:] True or False: You should use different Image List controls for storing images of different sizes.
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans05 5:] To see columns in a List View control, the View property must be set to what?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans06 6:] The additional columns of data that can be attached to an item in a list view are stored in what collection?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans07 7:] What property of what object would you use to determine how many items are in a List View?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans08 8:] Each item in a Tree View is called a what?
[file:///C:/Documents%20and%20Settings/dani/Asztal/c%23in24h/app01lev1sec8.htm#ch08ans09 9:] How do you make a node the child of another node?
Exercises
  1. Add a second Image List to your project with the List View. Place an icon (32x32 pixels) in this Image List and link the Image List to the LargeImageList property of the List View control. Change the View to Large Icons. Does the icon appear next to a list item? If not, is there a property of an item you can set so that it does?
  2. Create a new project and add a List View, a button, and a text box to the default form. When the button is clicked, create a new item in the List View using the text entered into the text box.