Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Superscript in column header
posted

Mike, 

I need to display column header captions with superscript and subscript.(need not be at run time)

I have used graphics object and DrawString method to acheive the same but in a simple label control on a Windows Form.

Some part of the Code:

Size SubSize = Size.Round(e.Graphics.MeasureString(labelText, NormalFont, new Size(Int32.MaxValue, Int32.MaxValue), StringFormat.GenericTypographic));

e.Graphics.DrawString("Omega", SubScriptFont, labelForeColorBrush, SubSize.Width, SubSize.Height / 2, StringFormat.GenericTypographic);

I need the same functionality in the Ultragrid column header.

I am trying to use the DrawFilter and DrawParams(Graphics.DrawString)

Any suggestions ?

 public Infragistics.Win.DrawPhase GetPhasesToFilter(ref Infragistics.Win.UIElementDrawParams drawParams)

{

if (drawParams.Element is HeaderUIElement)

return DrawPhase.BeforeDrawForeground;

else

return Infragistics.Win.DrawPhase.None;

}

public bool DrawElement(Infragistics.Win.DrawPhase drawPhase, ref Infragistics.Win.UIElementDrawParams drawParams)

{

HeaderUIElement headerElem = drawParams.Element.GetAncestor(typeof(HeaderUIElement)) as HeaderUIElement;if (headerElem != null)

{

string caption = headerElem.Header.Caption;

SolidBrush labelForeColorBrush = new SolidBrush(base.ForeColor);

drawParams.Graphics.DrawString(caption, NormalFont, labelForeColorBrush, 0, 0, StringFormat.GenericTypographic);

Size SubSize = Size.Round(drawParams.Graphics.MeasureString(caption, NormalFont, new Size(Int32.MaxValue, Int32.MaxValue), StringFormat.GenericTypographic));

drawParams.Graphics.DrawString("Acw", SubScriptFont, labelForeColorBrush, SubSize.Width, SubSize.Height / 2, StringFormat.GenericTypographic);

return true;

}

return false;

}

  • 469350
    Offline posted

    Hi Madhavi,

    What part of this is giving you trouble? If you can do this for a label, then the Column Header in the grid shouldn't really be much more complicated. The hardest part will be finding the correct UIElement that draws the text. The easiest way to do this is by using the Infragistics UIElementViewer Utility