473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C#-App: Textbox scroll bar showing double byte characters

71
Hi everyone,

I have a textbox which is multiline and wordwrap is true.
I did not set any scrollbar because I want to show it manually (using different buttons)
The textbox will sometimes have double byte strings (chinese characters)

Question:
1) How can I know if I need to show the scrollbar base on the text inside the textbox?

Options:
1) is there a way to manually predict the number of characters that my textbox can show within its size? Getting the length of the string just show the number of characters in the string, not the actual space it can occupy inside the textbox


TIA

dantz
May 28 '09 #1
1 3085
@dantz
Hi dantz!

This might be a moot point - not sure I understood your situation correctly. But at least with non-chinese (or other multi-byte) characters this should work....

You can measure the amount of pixels it takes to draw a string by using the MeasureString-method from the System.Drawing.Graphics - object.

Expand|Select|Wrap|Line Numbers
  1. SizeF size = g.MeasureString("string to measure here", this.Font);
You will want to use the Font from your Textbox object. Now you only need to get a hold of Graphics object. One way is to override the OnPaint method like t his:
Expand|Select|Wrap|Line Numbers
  1. protected override void OnPaint(PaintEventArgs e)
  2. {
  3. // e.Graphics has reference to Graphics used
  4. }
Or if that wont do, you can do it once in your form's OnLoad like this:
Expand|Select|Wrap|Line Numbers
  1. System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(this.Handle);
That should get you started solving your problem.

You will have some troubles with "borders" of the text box. I mean that the size of the textbox object is likely to be different from the area where you can actually draw strings...

HTH,
salmenmikko
Jun 29 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Vincent Zhu | last post by:
I moved ASP WebPages from Windows 2000 server to Windows 2003 server platform. Those double-byte characters (Japanese) retrieved from SQL server 2000 are corrupted. I am using Macromedia...
2
by: Tharika | last post by:
Hi, I have a web page with a <select> listbox that contains both English strings and Kanji-character strings in the options. The charset on the page is set to UTF-8 and on load of the page, both...
3
by: tony wong | last post by:
is it possible to detect any double-byte character in the text? thanks. tony
2
by: RodBillett | last post by:
I have an ASP.NET web page that accepts querystring parameters. MyPage.aspx?DB=__??????????&ID=1 When I get into the page and look at Request.Querystring it shows as ...
1
by: sid | last post by:
Hello, I have got a requirement in my project where there is a NAME column in a table which will contain double byte Japanese characters .I have SORT results by this NAME column which contains...
1
by: param | last post by:
Hi Everybody, Here i am working on a struts project for japanese. from the front end user may type email id in text box. Here if user enters double byte character mail id, then i have to convert...
0
by: jags_32 | last post by:
Hello We use MFG-PRO as our ERP system which in turn uses Progress databases. In the old version of SQL 2000, using DTS packages, we used to set the code page via command prompts and execute DTS...
198
by: Antoninus Twink | last post by:
Or, just how low has this group sunk? Twice in the past couple of days, Default Loser has accused Chris Hills, member of the ISO C committee, of being a troll (though given that the former's...
1
by: amollokhande1 | last post by:
Hi All, I want to build an application that will convert the english characters into other languages like Chinees, Japanies etc using VB.net. I am looking for use of Double byte character set for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.