Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:24:26+00:00 2026-05-23T05:24:26+00:00

I am trying to set a property that is an enum using an integer

  • 0

I am trying to set a property that is an enum using an integer value, like

Graphics g = this.CreateGraphics();
int enumValue = 2; // corresponds to SmoothingMode.HighQuality
g.SmoothingMode = (SmoothingMode)2; // does not have expected result
// also tried:
SmoothingMode sm = (SmoothingMode)Enum.ToObject(typeof(SmoothingMode), enumValue); // works correctly
g.SmoothingMode = sm; // still doesn't work!

But the object’s property never gets set to the correct enum value. I’ve run this through VS2010’s debugger and the casting and/or use of Enum.ToObject works correctly, but after the assignment, g.SmoothingMode is AntiAlias instead of HighQuality, for example. In fact, no matter what number I cast, the assignment always results in either AntiAlias (int equivalent 3) or None (int equivalent 4) being assigned to the object’s property.

Is there something different about when an enum is a property of a class that affects casting & assignment, or just something weird about Graphics.SmoothingMode, or what?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:24:27+00:00Added an answer on May 23, 2026 at 5:24 am

    Take a look at SmoothingMode Enumeration description.

    Quote:

    Default , None, and HighSpeed are
    equivalent and specify rendering
    without smoothing applied.

    AntiAlias and HighQuality are
    equivalent and specify rendering with
    smoothing applied.

    So basically there are three modes:

    • antialiased rendering (HighQuality, AntiAlias)
    • no antialiasing (Default, None, HighSpeed
    • invalid (Invalid)

    There is no problem with the enumeration in your code. The following line is legit.

    g.SmoothingMode = (SmoothingMode)2;
    

    It just internally treats HighQuality the same way as it does AntiAlias.

    If you do:

    g.SmoothingMode = SmoothingMode.HighQuality;
    var x = g.SmoothingMode;
    

    x will return SmoothingMode.AntiAlias as this basically the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use mock to verify that an index property has been set.
I'm having trouble trying to set the value of a property after i cast
Trying to develop using MVVM: I have this Csla.PropertyStatus control that is created in
I'm trying to set the fetchmode to eager for a property that is two
I'm trying to set a view's backgroundColor based on a property that I set
I am trying to set a property of tab(0) at tab(1). This is what
I am trying to set a property of an element using DataTrigger in a
I'm trying to create a custom object that behaves properly in set operations. I've
I am trying to set textColor property of button in android 2.1. But I
Pardon me if it is nave; but i am trying to set a property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.