FlexChart ToolTips Color

Posted by: khoitsma on 15 December 2020, 5:56 am EST

    • Post Options:
    • Link

    Posted 15 December 2020, 5:56 am EST - Updated 3 October 2022, 2:29 pm EST

    Using trial version of GC Components,

    In WinForm Flexchart CS

    Trying:

    flexChart1.ToolTip.BackColor = Color.LightYellow;

    flexChart1.ToolTip.ForeColor = Color.Blue;

    Neither of these change the look of my tooltip.

    Sounds correct ??

  • Posted 16 December 2020, 7:15 pm EST

    Hi Karl,

    Thank you for sharing the code snippet and snapshot.

    This is the default behavior of MS Tooltip (Winforms) as it doesn’t allow us to directly change its appearance. However, we can custom draw the tooltip in order to change its appearance by setting ToolTip’s OwnerDraw property to true and handle its Draw event as follows:

    
    flexChart1.ToolTip.OwnerDraw = true;
    flexChart1.ToolTip.Draw += (s, e) =>
    {
          var background = new SolidBrush(Color.Yellow);
          var foreground = new SolidBrush(Color.Red);
    
          var format = new StringFormat()
          {
              Alignment = StringAlignment.Center,
              LineAlignment = StringAlignment.Center
          };
    
          e.Graphics.FillRectangle(background, e.Bounds);
          e.DrawBorder();
          e.Graphics.DrawString(e.ToolTipText, e.Font, foreground, e.Bounds, format);
    
          format.Dispose();
          background.Dispose();
          foreground.Dispose();
    };
    
    

    Please refer to the same from the attached sample. (see FlexChartTooltip.zip)

    Just in case, if you want to set Html content as tooltip you may also refer to the Tooltips section of the product sample present at location Documents\ComponentOne Samples\WinForms\v4.5.2\FlexChart\CS\FlexChartExplorer\FlexChartExplorer\Samples\ChartElements

    Regards,

    Kartik

  • Posted 16 December 2020, 7:16 pm EST

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels