Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008 C#
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 4:28am
vishal_h1.7K
Edited 28-Jan-13 4:29am
v2

1 solution

Rate this: bad
good
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).
  Permalink  
Comments
vishal_h at 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
0 Sergey Alexandrovich Kryukov 520
1 mhegazy94 460
2 Ravi Bhavnani 230
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,205
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,644
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
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