How to get number of word wrap breaks in richtextboxusing c#? - word-wrap

I am working with the rich text box where i need to in crease its size whenever i get the word wrap....as of now i m just counting the number of character and if character goes above the limit i m just changing the height of the rich text box.... I know this is not proper way so i m searching for answer where i can get the word wrap count. So i can increase the height that many times....Please Help me.....
Thanks in advance.....

Couldn't you check the VerticalScrollBarVisibility property to determine whether there is a scroll bar - and increase the height if there is?

Related

How to measure margin between font-elements in XD?

It seems not possible to view the exact margin between font-elements in XD (dev-view). Below you'll find a screenshot of a situation where we need to measure the exact distance between two Font-elements (XD developer-view).
It needs to bypass the line-height, but it doesn't. To be able to do this, we need the line-height to be zero. But when we edit the line-height in XD for a word or sentence on a single row, XD does not change that line-height.
Anybody encountered the same situation?
In this example the line-height is 32. We go to XD. Change it to zero, save it and SHARE FOR DEVELOPMENT. But the line-height remains 32. Also changing it to 1 instead of zero won't make any difference.
To fix this issue, you have to select the Text within Adobe XD. Right Click and select Path > Convert to Path. The margins around the Text will disappear and when in DEVELOPMENT view it becomes possible to see the right margin. A small problem remains. When you want to edit the text when it's a shape, you have to delete it and place a new text and turn it into a shape again. the text when converted to a shape
The default selector in Adobe XD will not give you the exact margin between two text. You have to convert the text layer into paths (Convert to Outlines) to get the exact margin.
But remember after converting text layer into path the text cannot be edited because now the letter are separate vector shapes.
To convert text layer into Path, select the layer and goto Object>Path>Click Convert to Path
You can use the Guides to drag one below your text and another one on top of the second text, and then you can see the distance between the 2 guides.
Check this youtube video for a quick tutorial on it. This is going to be a manual action. I don't think there's a key to press to check the distance automatically.

Position of Text in a TextBox

Hi I have a textbox containing some text. I am looking to replicate the red spelling mistake squiggle type behaviour.
Using WinAPI I can
draw the squiggle between 2 points.
find out the height and width of
the word to be "squiggled".
What is the api call (or perhaps the methodology if it is more than a single api call) to find the position of that word in the text box so that I can position the sqiggle undeneath it.
Also, what are the messages I need to trap to ensure that the squiggle is redrawn. I'm currently only using WM_PAINT, which obviously isn't good enough.
EDIT (3 Sept 2012):
FYI, Here's where I got to so far. Needs a lot of refining but shows basic principles
https://gist.github.com/3607272
Many thx
S
What might work is using an auto-sized label. Make sure the fonts in the label and textbox are identical.
Detect the number of rows that are before the sentence containing the misspelled word.
Fill the label caption with the number linefeeds (vbcrlf) you got from question 1.
Append the words from the misspelled line (up to the misspelled word) to the labels caption.
The label size should now be identical with the beginning of the misspelled word.
Example text:
This is my first line.
And my second line.
And over here i have my mispeled word.
Label caption output should be (ignore the dots, they are empty lines):
.
.
And over here i have my
The labels height and width should match the position in the textbox, unless you have scrollbars. If the textbox has borders then you should add a fixed value to the height and width to get an exact match.

How do I adjust the font size of a tetxblock control depending on the length of the text string that it contains?

I have a textblock and I pull items out of a database and I want to make the text fit on one line. How do I programmatically adjust the font size such that the entire line fits on the phone screen?
Thank you.
I ended up using what Jared Bienz linked to.

Adobe Flex 4 text height

I remember in Flex 3 text width/height could be calculated (not the text UI component but the text itself):
new Text().textHeight;
or
new Text().getTextField().measuredHeight;
Does anyone know how can that be done in Flex 4 with its Text Layout Framework now?
Thanks.
I've found an answer myself. If someone has any better ideas - you're welcome.
I use to assume that width of text content is not so important cause each time the size changes the value used below are updated. So I check the height of text (assuming width is fixed) as:
var textHeight: Number = (_text.textLines.length-1) * _text.textFlow.lineHeight + _text.textFlow.fontSize
where _text is s:RichText.
I needed to know whether the text inside did not exceeded the space available, that's why the only thing I need now is to check whether textHeight < _text.height
That's it. Be sure the text is rendered correctly before checking the height (I use to listen to UDPATE_COMPLETE event).

How can I resize an NSTextField to fit the text that it holds?

I'm using an NSTextField to display lines of text that will be printed on a printer with a variable paper size (the printer prints to a spool, which is cut to the appropriate length when the job is done).
I can generate the text no problem, but I need to know how big to make the NSTextField (vertically) so that it exactly contains all of the lines of text. Is there an easy way of going about this?
The text is prepared as an NSAttributedString, and the lines are all of a fixed width (no wrapping), if that helps.
There is a great category on NSString/NSAttributedString by Jerry Krinock which allows you to calculate the height of text based on its width and vice versa:
http://www.sheepsystems.com/sourceCode/sourceStringGeometrics.html
I've used this often and it works very well indeed.

Resources