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

Event Driven Programming






















                                                          Figure 3.8: TextBox.

                          3.4.1.1 Some Notable Properties

                          Some important properties in the behavior section of the Properties Window for TextBoxes.
                          Enabled: Default value is True. To disable, set the property to False. Multiline: Setting this
                          property to True makes the TextBox multiline which allows to accept multiple lines of text.
                          Default value is False. PasswordChar: Used to set the password character. The text displayed in
                          the TextBox will be the character set by the user. Say, if you enter *, the text that is entered in
                          the TextBox is displayed as *. ReadOnly: Makes this TextBox readonly. It doesn’t allow to enter
                          any text. Visible: Default value is True. To hide it set the property to False.

                          3.4.1.2 Appearance Section Properties
                          TextAlign: Allows to align the text from three possible options. The default value is left and you
                          can set the alignment of text to right or center.
                          Scrollbars:  Allows to add a scrollbar to a Textbox. Very useful when the TextBox is multiline.
                          You have four options with this property. Options are None, Horizontal, Vertical and Both.
                          Depending on the size of the TextBox anyone of those can be used.

                          3.4.1.3 TextBox Event
                          The default event of the TextBox is the TextChanged Event which looks like this in code:

                           Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As _
                           System.EventArgs) Handles TextBox1.TextChanged

                            ...
                           End Sub


                          3.4.1.4 Working With TextBoxes
                          Lets work with some examples to understand TextBoxes.
                          Drag two TextBoxes (TextBox1, TextBox2) and a Button (Button1) from the toolbox.
                          Code to Display some text in the TextBox


                          42                     LOVELY PROFESSIONAL UNIVERSITY
   43   44   45   46   47   48   49   50   51   52   53