Page 66 - Open Soource Technologies 304.indd
P. 66

Event Driven Programming



                           Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
                           System.Object,_
                           ByVal e As System.EventArgs) Handles
                           ComboBox1.SelectedIndexChanged
                           TextBox1.Text = ComboBox1.SelectedItem
                           ’selecting the item from the ComboBox with selected item property
                           End Sub
                          Removing items from a ComboBox
                          You can remove all items or one particular item from the list box part of the ComboxBox. Code
                          to remove a particular item by it’s Indexnumber looks like this:
                           Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
                           As_
                           System.EventArgs) Handles Button1.Click
                           ComboBox1.Items.RemoveAt(4)
                           ’removing an item by specifying it’s index
                           End Sub

                          Code to remove all items from the ComboBox

                           Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
                           As_
                           System.EventArgs) Handles Button1.ClickComboBox1.Items.Clear()
                           ’using the clear method to clear the list box
                           End Sub


                          3.4.8 Frame Control
                          The Visual Basic 6.0 Frame control is replaced by two controls in Visual Basic 2005: the Group
                          Box control and the Panel control.
                          3.4.8.1 Conceptual Differences
                          In Visual Basic 6.0, the Frame control is used as a container for grouping controls. In Visual Basic
                          2005, the Frame control is replaced by either the GroupBox control or the Panel control.
                          The GroupBox control is the equivalent of a Frame control with a BorderStyle property of 1
                          – Fixed Single. It has a visible border and optionally a caption.
                          The Panel control is the equivalent of a Frame control with a BorderStyle property of 0 – None.
                          It has no border or caption.
                          In addition, there are numerous conceptual differences that apply to all controls, including
                          differences in data binding, font handling, drag and drop, Help support and more.

                          3.4.8.2 Frame Control Property, Method, and Event Equivalencies
                          The following tables list Visual Basic 6.0 properties, methods, and events, along with their Visual
                          Basic 2005 equivalents. Those properties, methods, and events that have the same name and



                          60                     LOVELY PROFESSIONAL UNIVERSITY
   61   62   63   64   65   66   67   68   69   70   71