michael_hk Posted February 21, 2005 Posted February 21, 2005 Hi guys, I have a resizable multiline textbox. How can I get the number of characters a single line can accommodate? I can only find textbox.Width... Thanks. Michael Quote There is no spoon. <<The Matrix>>
Administrators PlausiblyDamp Posted February 21, 2005 Administrators Posted February 21, 2005 The main problem you will have is if you are displaying text with a variable width font - the number of characters is dependant on which characters are entered. You may get some mileage out of the MeasureString method... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders snarfblam Posted February 21, 2005 Leaders Posted February 21, 2005 Yes, the amount of chars will vary unless you use a font where the chars have a fixed width like courier new or lucida console, in which case you can use the Graphics.MeasureString() function to figure out how many chars you can fit. Quote [sIGPIC]e[/sIGPIC]
michael_hk Posted February 22, 2005 Author Posted February 22, 2005 Thanks for the info. Finally I use "Courier New 9 pt" and estimate the # of chars by nChar = textbox.Width / 10; // 10 pixel for a "Courier New 9 pt" letter The result is not very accurate, but fine for me. Thanks again for all your help. Michael Quote There is no spoon. <<The Matrix>>
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.