Click here to Skip to main content
13,408,620 members (48,831 online)
Rate this:
Please Sign up or sign in to vote.
I want to minimize the text box height to 8px how i can do..I try and done same with
text box multiline property true but problem with this now text box allow enter key which i dont want.Is any alternative way for this so textbox is same as normal text box but with less height than its default height(which is 20) i can show in application.
Posted 28-Jan-13 5:28am
Updated 28-Jan-13 5:29am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can't set a text box to a specific pixel height without selecting MultiLine - in which case it expects multiple lines as input, so it uses the ENTER key. Single line TextBoxes always resize to fit the Font size specified (Which makes sense, or the text in it would not be readable). So, You can chnage the Font size:
Set the TextBox Font property:
myTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 4F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
Will use a smaller textbox - I think you are making a mistake though. Most users adjust the monitor size to fit their eyesight, and a much smaller font may not be readable to them (or anyone else).
vishal_h 28-Jan-13 11:08am
thank you for your reply but my requirement is such that i want to show many text boxes in application in table format so i cant exceed height of each text box more than 15 px then what should i do at design time.To write a code for each text box is not feasible.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180221.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100