Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Convert stdole.IFontDisp to font

Posted on 2006-03-31
Medium Priority
Last Modified: 2013-12-03

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?
Question by:ruanlab123
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 16343321
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);


Author Comment

ID: 16343640
thank you very much, works 100%

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question