Results 1 to 6 of 6

Thread: Changing the height of a textbox with a button - Windows Form Application

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    12

    Post Changing the height of a textbox with a button - Windows Form Application

    Hello, very new to programming as a whole - how do I change the height of a text box with a button? The project I'm working on has a main textbox which is covers a search bar (and a smaller text box) for a different function on my Windows App Form, but I'm looking to shrink my main text box so that the search bar is visible for another function.

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    599

    Re: Changing the height of a textbox with a button - Windows Form Application

    Quote Originally Posted by JakeC View Post
    I'm looking to shrink my main text box so that the search bar is visible for another function.
    why shrink it when you can hide it :

    Code:
    Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
            If TextBox1.Visible Then
                TextBox1.Visible = False
            Else
                TextBox1.Visible = True
            End If
    
        End Sub
    you could also change the z order if you still want to see some of it
    Last edited by Delaney; Apr 15th, 2021 at 02:07 PM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  3. #3
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,185

    Re: Changing the height of a textbox with a button - Windows Form Application

    More to Delaney's suggestion, since the Visible property returns a Boolean, you can toggle the visibility by using the Not keyword:
    Code:
    TextBox1.Visible = Not TextBox1.Visible

  4. #4
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    599

    Re: Changing the height of a textbox with a button - Windows Form Application

    Quote Originally Posted by dday9 View Post
    More to Delaney's suggestion, since the Visible property returns a Boolean, you can toggle the visibility by using the Not keyword:
    Code:
    TextBox1.Visible = Not TextBox1.Visible
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    12

    Re: Changing the height of a textbox with a button - Windows Form Application

    [QUOTE=Delaney;5518207]why shrink it when you can hide it :

    So, the problem I have now is I've already hidden the main textbox for a different function. These functions are List and Edit, List shows a read-only textbox and Edit shows a normal textbox. How do I make it so I can switch between both modes at will without any overlapping?

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    106,688

    Re: Changing the height of a textbox with a button - Windows Form Application

    The question doesn't really make sense as asked because, unless it's multiline, the Height of a TextBox is determined by its Font. You should absolutely be either hiding and showing the specific controls you want at any specific time or putting sets of controls on Panels and then changing the z-order so the Panel you want is in front. Rather than the vague and confusing description you have provided, be clear about what you want. Tell us exactly what you want to happen in exactly what scenarios, i.e. "I want to see A when X, B when Y, etc". If screenshots would help clarify, provide them. Once we know what you actually want, we can provide the best advice to achieve it.

Posting Permissions

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



Click Here to Expand Forum to Full Width