hi I have RichTextBox bind to description(html format) from database and it is read only. I just need to show First line from description. How to achieve this
As Silverlight has no way of measuring the width of fonts, you'll need to take an arbitrary amount of the text, and simply Substring() it.
Related
I am using the standard textbox control on a Windows form. I want to display the text VERTICALLY rather than horizontally. To accomplish this I set the multiline property to true, the TextAligh property to center and used the lines property to input each character as a separate array element. So far, so good.
I see the text displayed the way I want but would like to reduce the vertical spacing between lines without reducing the font size. Can it be done? If so, how?
It can be done, but not by the default options on a standard textbox.
You would probably need to override the Paint event and draw the text yourself, but it would get very ugly, and would essentially be reinventing the standard Paint method.
I want to show some text inside the MemoEdit in two columns. The parse of the text works correctly because when I see the parsed text inside Notepad or when I debug it inside Visual Studio it shows it in two columns, so the text is formatted exactly in the way I need it. The problem is that when it is shown inside the MemoEdit, it doesn't keep the format (I think this is because it uses a different font for the text, not a fixed size width font, because white spaces are smaller then normal characters). I changed the font to some fixed size width font and is showing it correctly, but the problem is that I need to have the same font like the application uses. Is there any property on MemoEdit that can help me achive the behavior I want without changing the font?
Thanks a lot!
You can activate the RowAutoHeight option of the GridView.OptionsView property in GUI and you can set it pragmatically as below:
gridView1.OptionsView.RowAutoHeight = true;
You can also use CalcRowHeight event handler to tweak the height of the gridview rows. check the reference links.
Reference these DevExpress fourm thread -
Auto-height of grid rows and text WordWrap
GridControl row height (cell height)
Changing row height at runtime
I have a string to draw in a custom dialog box. How can i get the required length of string in pixels using WPF?
If you want to show it afterwards within a TextBlock, create the TextBlock and call Measure and Arrange. Make sure that the TextBlock has set the right font size before calling Measure.
Another way is to go via FormattedText, if you want to do your calculations on a low level.
You might not need the (pixel) size.
It might be better to automatically size the dialog to its content.
Hi Guyz I have a WPF TextBlock of fixed width say 100 , If the string doesnt fit in the width the last character is being cutoff always as all the characters are of not the same size. I dont want to cut the character instead I want to skip the text from there and just display the text with no character cutoff.
You have a couple of options to control wrapping and cutting of text:
TextWrapping can be used to make the text flow to the next line
TextTrimming can be used to decide how to cut text that doesn't fit
TextTrimming=None (the default) will mean that text which doesn't fit will be hidden, but it may cut down the middle of a character, which sounds like the problem you describe.
TextTrimming=WordEllipsis or TextTrimming=CharacterEllipsis will avoid showing half a character, but will append "..." to the end of the text. That will probably look better to users.
If you want to cut off the extra characters without adding the ellipsis, you'd have to use the technique Ed S. described
I suppose that I don't really understand your use case here. My first suggestion would be to simply dynamically size your TextBlock. If that's not possible then you wil have to get the width of the string and manipulate it yourself before you set it in the TextBlock (or use a fixed width font assuming that you can and you know the max length of the string).
If you need to measure the width of the string before it is displayed you can use the FormattedText class to do so.
Ok I have the following problem in Silverlight. I have a control with 2 columns. On the left is a stack panel with line numbers and on the right is a textBox.
So when I write in textBox without wrapping turned on I can simply create the right count of numbers on the left, because I'm searching for '\r' in text.
But when I turn on wrapping I have no control over the count of lines in textBox.
Is there a way to get to that count? Or a way to know which line in textBox is going to wrap?
I hope you can understand what I'm trying to do.
There's one way to do this. You can simulate the word wrap operation in the background using a TextBlock. Here is a good link of the complete solution to this problem.
Extended TextBox control with MaxLines property
Is it not possible to create your items in code before they are passed to the view. This would enable you to bind a list of items to a listview and style them as you wish.
You need to user a value converter to count the number of char / lines and then trim that number if you wish to. Unless you use fixed width, you can't really count or calculte in advancet the size, since each application might be displayed differently (due to different sizing option).
There are two great sample chapters on Windows Phone and Silverlight for Windows Phone on the LearningWindosPhone.com site. There is great Windows Phone Trainng material , and dont forget the Windows Phone Develoeprs Blog
Yes there is a way to get the number of lines occupied by the text in the textbox. It's not that simple though 'coz you have to simulate the behavior of the word wrap in order to count/predict the number of lines generated as a result of a word wrap. I have the solution described here in detail.