We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Convert stdole.IFontDisp to font

ruanlab123
ruanlab123 asked
on
Medium Priority
2,083 Views
Last Modified: 2013-12-03
Hi

I am busy with a report designer application in C# using the Crystal Reports design lybaries - CRAXDDRT.
I've created a font object : public Font objectFont and wants to assign the objectFont to a spesific reportfield font.

CRAXDDRT.TextObject textfield;
textfield = (CRAXDDRT.TextObject)Report.Sections[Section].ReportObjects[RepObj];

objectFont = textfield.font;

But the following error occurs : Error      2      Cannot implicitly convert type 'stdole.IFontDisp' to 'System.Drawing.Font'      

How can I convert a stdole.IFontDisp to System.Drawing.Font?
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
Maybe something like this:

FontStyle style = FontStyle.Regular;

if (textfield.Bold)
  style |= FontStyle.Bold;
if (textfield.Italic)
  style |= FontStyle.Italic;
if (textfield.Underline)
  style |= FontStyle.Underline;

Font font = new Font(textfield.Name, textfield.Size, style);

Bob

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
thank you very much, works 100%
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.