Show current textbox descr on statusbar-VBForums
Results 1 to 3 of 3

Thread: Show current textbox descr on statusbar

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    11

    Show current textbox descr on statusbar

    Say you have a form and on it you have 3 TextBox's. Now you want to color the textbox's and at the same time show a discription on the status bar of your application the discription of the TextBox (I use the ToolTip.Text).
    What usualy is done is the same code for all textbox controls. Now, say you have a form that has 300 textbox's on it. What do you do? Well I have created the following code to overcome lots of line of code.

    place this in a module:
    Code:
        Private Sub TextBox_Enter(ByVal Sender As Object, ByVal e As System.EventArgs)
            Sender.BackColor = Color.LemonChiffon
            fSysStartUp.StatusStrip1.Items("ToolStripStatusLabel1").Text = Sender.FindForm.ToolTip1.GetToolTip(Sender).ToString()
        End Sub
    
        Private Sub TextBox_Leave(ByVal Sender As Object, ByVal e As System.EventArgs)
            Sender.BackColor = Color.FromKnownColor(KnownColor.Window)
        End Sub
    
        Public Sub AccociateTextBoxEventHandler(ByVal myControlIN As Control)
            For Each myControl As Control In myControlIN.Controls
                AccociateTextBoxEventHandler(myControl)
    
                Dim AllTextBoxes As TextBox
                If TypeOf myControl Is TextBox Then
                    AllTextBoxes = myControl
                    AddHandler AllTextBoxes.Enter, AddressOf TextBox_Enter
                    AddHandler AllTextBoxes.Leave, AddressOf TextBox_Leave
                End If
            Next
        End Sub
    and then this in the Load event of the form.
    Code:
    AccociateTextBoxEventHandler(Me)
    Last edited by si_the_geek; Feb 3rd, 2011 at 06:11 AM. Reason: added Code tags

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,565

    Re: Show current textbox descr on statusbar

    The VB.NET forum is for asking questions about VB.NET. If you want to share code snippets or the like with others then you should post them in the VB.NET CodeBank forum. I have asked the mods to move this thread.

    With regards to your code, I have one issue. I strongly recommend that everyone turns Option Strict On for every project and only turns it Off in code files that specifically need to make use of late-binding. Your code uses late-binding so you obviously have Option Strict Off. I'd strongly suggest turning it On and casting as required.

    Also, please use the Code or VBCode buttons to wrap your code snippets in formatting tags to make them easier to read.

    Nice job apart from that though.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    37,191

    Re: Show current textbox descr on statusbar

    Thread moved from the 'VB.Net' forum to the 'CodeBank VB.Net' forum (thanks for letting us know jmcilhinney )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.