Hi,
is it possible to identify if a text in a UltraWinEditor is truncated (no multiline, no text wrapping).
Cheers,
Michael
Michael,
The EditorWithTextUIElement exposes a property to indicate whether all of the text is currently visible:
using Infragistics.Win;
...
bool isTruncated = false;EditorWithTextUIElement element = this.ultraTextEditor1.UIElement.GetDescendant(typeof(EditorWithTextUIElement)) as EditorWithTextUIElement;if (element != null) isTruncated = !element.IsDataFullyVisible;
-Matt
I'm trying to do something similar, but after setting the text and size, I used your code to see if it the data is fully visible and it keeps returning false. I I keep adding to the width, but it still says it's false. Am i doing something wrong?
P.S. I have a text box with WordWrap = True and MultiLine = True.
UPDATE: My textbox has the property "AlwaysInEditMode" set to true because i want the scroll bars to be visible. I think this may be the problem. Is there a way around this?
hoahuynh said:I'm trying to do something similar, but after setting the text and size, I used your code to see if it the data is fully visible and it keeps returning false. I I keep adding to the width, but it still says it's false. Am i doing something wrong? P.S. I have a text box with WordWrap = True and MultiLine = True. UPDATE: My textbox has the property "AlwaysInEditMode" set to true because i want the scroll bars to be visible. I think this may be the problem. Is there a way around this?
The code I had posted won't work for an UltraTextEditor that's in edit mode, or for any control that uses a .NET TextBox for the underlying editor. What needs to be done in this case is actually measure the string and see if it would require more space than is actually available to the editor, such as:
bool isTruncated = false;if (!this.ultraTextEditor1.IsInEditMode){ EditorWithTextUIElement element = this.ultraTextEditor1.UIElement.GetDescendant(typeof(EditorWithTextUIElement)) as EditorWithTextUIElement; if (element != null) isTruncated = !element.IsDataFullyVisible;}else{ using (Graphics g = this.ultraTextEditor1.CreateGraphics()) { SizeF textSize = DrawUtility.MeasureString(g, this.ultraTextEditor1.Text, this.ultraTextEditor1.Font, this.ultraTextEditor1.Width); if (textSize.Height > this.ultraTextEditor1.Height || textSize.Width > this.ultraTextEditor1.Width) isTruncated = true; }}
This was just a quick test that I did, so I'm not sure that getting the Font off of the control will return the properly resolve font. Additionally, this seems to be a couple pixels off, so you may have to account for the border sizes and subtract that from the width passed into the MeasureString function.