Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
2.00/5 (1 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
Updated 28-Jan-13 4:29am
v2

1 solution

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:
C#
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).
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900