PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2017 Textbox that can set height manually-VBForums
Results 1 to 6 of 6

Thread: Textbox that can set height manually

  1. #1

    Thread Starter
    Fanatic Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    905

    Textbox that can set height manually

    Hi,

    For a textbox the height property is set by size of font. I can use hidden property to adjust height:

    Me.TextBox1.AutoSize = False
    Me.TextBox1.Height = 20



    This works...but the vertical alignment of the text inside the textbox is wrong then, also because I have many textboxes to align everything everywhere is troubling (because the size I want only is there at run time - set by code) and also some looks not properly aligned (the reason for this is because I don't have borders on my textboxes - I wish for it to be without borders) Once I set BorderStyle to "None" it becomes a problem.

    Is there maybe a class for a custom textbox that I can do please? I want to set the height of a textbox and that textbox does not have borders. Also after I set the height of the textbox the text must be vertical aligned middle and left.



    Thanks....
    Last edited by schoemr; Mar 14th, 2019 at 09:38 AM.
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    33,612

    Re: Textbox that can set height manually

    Do you want people to be able to type in the textbox, or just to display items? If you need them to be able to enter and edit stuff, then you have fewer options. If this is only for display, then you have more options.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Fanatic Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    905

    Re: Textbox that can set height manually

    Quote Originally Posted by Shaggy Hiker View Post
    Do you want people to be able to type in the textbox, or just to display items? If you need them to be able to enter and edit stuff, then you have fewer options. If this is only for display, then you have more options.
    Hi Shaggy, yes I want people to type in the textboxes.. Maybe if there is a way to adjust the colour of the textbox border?

    I implemented this:

    https://www.codeproject.com/Articles...TextBox-Height

    It is working.. I can adjust the height of textbox - but this too does not work if textbox BorderStyle = None

    So maybe I must try to keep the border style FixedSingle but make the border color white - if that is possible...
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,994

    Re: Textbox that can set height manually

    If you use this custom control instead of the regular TextBox:
    vb.net Code:
    1. Imports System.ComponentModel
    2.  
    3. Public Class TextBoxEx
    4.     Inherits TextBox
    5.  
    6.     <Browsable(True)>
    7.     <Category("Layout")>
    8.     Public Overrides Property AutoSize As Boolean
    9.         Get
    10.             Return MyBase.AutoSize
    11.         End Get
    12.         Set
    13.             MyBase.AutoSize = Value
    14.         End Set
    15.     End Property
    16.  
    17. End Class
    then you'll get access to the AutoSize property at design time. That won't help you with alignment though. Given that your TextBox has no border, one option would to place the TextBox inside another control that has the same BackColor. For instance, if you use a TableLayoutPanel with three rows and a single column then you can put the TextBox in the middle cell and then force it to be middled vertically. To the user, it will just look like one control with the text in the middle-left.

  5. #5

    Thread Starter
    Fanatic Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    905

    Re: Textbox that can set height manually

    Hello John,

    Wow.. this is new to me... A control can "inherit" from another control..

    Thank you!!
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

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

    Re: Textbox that can set height manually

    Given that the CheckedListBox class inherits the ListBox class, I guess so. Similarly, the TableLayoutPanel and FlowLayoutPanel classes inherit the Panel class. Many have abstract classes in their inheritance chain, e.g. TextBox and RichTextBox both inherit TextBoxBase, as does MaskedTextBox. They are all just classes, like any other, with the caveat that they all inherit the Control class at some point.

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