I need dotted line under the text of each cell. Something link url link that need to be dotted line rather fixed horizontal straight line. My code goes as follows.
ultraGrid1.DisplayLayout.Bands[0].Columns[colIndex].CellActivation = Activation.NoEdit; Infragistics.Win.FormattedLinkLabel.UltraFormattedTextEditor urlLinkEditor = new Infragistics.Win.FormattedLinkLabel.UltraFormattedTextEditor(); urlLinkEditor.TreatValueAs = Infragistics.Win.FormattedLinkLabel.TreatValueAs.URL; urlLinkEditor.LinkClicked += new Infragistics.Win.FormattedLinkLabel.LinkClickedEventHandler(urlLinkEditor_LinkClicked); urlLinkEditor.UnderlineLinks = Infragistics.Win.FormattedLinkLabel.UnderlineLink.Always; urlLinkEditor.LinkAppearance.ForeColor = Color.Black; urlLinkEditor.VisitedLinkAppearance.ForeColor = Color.Black; urlLinkEditor.ScrollBarDisplayStyle = Infragistics.Win.UltraWinScrollBar.ScrollBarDisplayStyle.Never; ultraGrid1.DisplayLayout.Bands[0].Columns[colIndex].EditorComponent = urlLinkEditor;
I am getting the fixed line under the text but not dotted one. It would be really helpful if someone help me to acheive this. Thanks!
To the best of my knowledge what you are describing is not even possible using .NET string rendering methods (Graphics.DrawString), since the Font class does not extend this functionality. You would probably have to use the IUIElementDrawFilter interface to draw the line manually.
I guess we could only alter the border of the cell using the IUIElementDrawFilter. is it possible to draw the dotted line below the text of the cell. Do u have any sample code.
Hi,
Thanks for the sample code. It works for me. But the dotted line is not formatted. I need to draw the line to the lenght of text inside the cell exactly. But this one always draw from left end to right end irrespective of the text lengh. Please help me to achieve this. thanks for the support
Hello Uthayakumar, I am just checking about the progress of this issue. Did you solve your issue accordingly to the information that I provided you? Did you test the sample I have sent to you? Let me know if you need any further assistance.
TextSectionUIElement
tse = (TextSectionUIElement)drawParams.Element.GetDescendant(typeof(TextSectionUIElement));
As i dont have any descendant i get nul in tse. I got simple grid with row and columns. No tree view or anything.
This is how i have written code. And this is works for me.
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) {
TextUIElement textval = (TextUIElement)drawParams.Element;
if (string.IsNullOrEmpty(textval.Text)) return false; if ((textval == null) || (textval.Parent == null)) return false;
Rectangle rect = drawParams.Element.Rect; Point pt1 = Point.Empty; Point pt2 = Point.Empty; pt1.Y = rect.Top + (rect.Height) - 4; pt1.X = rect.Left + (textval.Text.Length * 6) ; pt2.X = rect.Right - (rect.Width) + 2; pt2.Y = pt1.Y;
using (Pen pen = new Pen(drawParams.TextBrush)) { Point pt = Point.Empty; pt.X = rect.X; pt.Y = rect.Y; pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; if (textval.Text != "Field") drawParams.Graphics.DrawLine(pen, pt1, pt2); drawParams.Graphics.DrawString(textval.Text.ToString(), drawParams.Font, drawParams.TextBrush, pt); }
return true; }
DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { return drawParams.Element is Infragistics.Win.TextUIElement ? Infragistics.Win.DrawPhase.BeforeDrawElement : Infragistics.Win.DrawPhase.None; }
But pt1.X = rect.Left + (textval.Text.Length * 6) ; this value measures my dotted horizontal line lenght. This is not accurate when text sometimes has numerical or caps values.
Please help me in this.
TextUIElement exposes a TextArea property, which is the rectangle that encloses the text of the element. You should probably use that rect, because what you are doing now is based on the assumption that each character is 6 pixels wide, and also that each character is the same width, both of which are not always true.
Thank you