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!
Thank you
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.
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.
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.
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.