Odd HTML Formatting of ScreenTip

3 posts, 1 answers
  1. Kurt Boyer
    Kurt Boyer avatar
    10 posts
    Member since:
    Mar 2013

    Posted 14 Oct 2015 Link to this post

    I'm using the RadOffice2007ScreenTipElement to show errors for rows within my RadGridView. When the ScreenTip displays, the html text is shown with weird spacing and odd vertical alignment for certain words.

     I've attached a screenshot of what I'm seeing. Take a look at the ScreenTip and notice the word "job" within the error "Blank job group code." There also seems to be extra spacing after that word, and after the word "EEO".

     Here is the relevant code snippet:

    private void RadGridView1_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e)
    {
      var cell = e.Item as GridDataCellElement;
      if (cell != null)
      {
        switch (cell.ColumnInfo.Name)
        {
          case "errorimage":
              int rowIndex = radGridView1.Rows.IndexOf(radGridView1.CurrentRow);
              if (rowIndex > -1)
              {
                if (cell.RowElement.RowInfo.Cells["errortext"].Value.ToString() != "")
                {
                  var screenTip = new RadOffice2007ScreenTipElement();
                  screenTip.CaptionLabel.Margin = new Padding(3);
                  screenTip.CaptionLabel.Text = "Job Error(s)";
                  screenTip.MainTextLabel.Text = cell.RowElement.RowInfo.Cells["errortext"].Value.ToString().Trim();
                  screenTip.EnableCustomSize = true;
                  e.Delay = 50;
                  e.Item.ScreenTip = screenTip;
                }
                else
                {
                    e.Item.ScreenTip = null;
                  }
              }
              break;
            default:
                break;
        }
      }
    }

    Is there any way to fix this?

  2. Answer
    Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 19 Oct 2015 Link to this post

    Hello Kurt,

    Thank you for writing.

    The Html-like feature has a known issue related to the incorrect painting because some fonts do not report correctly their text metrics. For example, Segoe UI and Tahoma with font size 8.5 do not render correctly - they report incorrectly some text metrics and changing the font to Segoe UI with size 9 (or Verdana 8.25, which looks pretty good) fixes the incorrect rendering. As a solution I can suggest the following:

    RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();
    screenTip.CaptionLabel.Margin = new Padding(3);
    screenTip.CaptionLabel.Text = "Job Error(s)";
    screenTip.MainTextLabel.Font = new System.Drawing.Font("Verdana", 8.25f);

    Alternatively you can also achieve a good result by setting the TextWrap property to false:
    RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();
    screenTip.CaptionLabel.Margin = new Padding(3);
    screenTip.CaptionLabel.Text = "Job Error(s)";
    screenTip.MainTextLabel.TextWrap = false;

    I am sending you a attached screenshots showing the result on my end using either approach.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kurt Boyer
    Kurt Boyer avatar
    10 posts
    Member since:
    Mar 2013

    Posted 19 Oct 2015 in reply to Hristo Link to this post

    This works perfectly. Thank you very much Hristo! :)
Back to Top