Convert stdole.IFontDisp to font

Posted on 2006-03-31
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

    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);

    LVL 1

    Author Comment

    thank you very much, works 100%

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    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…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now