How to determine text width of a TextObject at runtime

If at design time, I place a text object onto the surface, and set its anchor to Top and Right, and set HorzAlign to Right, and AutoWidth to True, after previewing the report the text will appear right-justified as expected with correct width.

Performing these steps at runtime is not giving the same results however, and the text appears far off to the right off the page.
If I cannot use AutoWidth on right-justified text at runtime, is there a way to calculate the width of the text?
I know about Graphics.MeasureString, but I don't see a reference to a Graphics object on the report to do such a calculation.

Help is appreciated!
private void button4_Click(object sender, EventArgs e)
        {
            Report report = new Report();
            report.CreateUniqueName();

            FastNameCreator nameCreator = new FastNameCreator(report.AllObjects);

            ReportPage page = new ReportPage();
            report.Pages.Add(page);
            nameCreator.CreateUniqueName(page);

            page.Overlay = new OverlayBand();
            page.Overlay.Height = Units.Inches * 10.0f;

            TextObject textObject = new TextObject();
            textObject.Parent = page.Overlay;
            nameCreator.CreateUniqueName(textObject);

            textObject.Top = Units.Inches * 1.0f;
            textObject.Height = Units.Inches * 0.5f;

            textObject.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
            textObject.AutoWidth = true;
            textObject.Left = Units.Inches * 3.0f;
            textObject.HorzAlign = HorzAlign.Right;

            textObject.Text = "Hello World";

            report.Show();
        }

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.