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

  • SEARCH
  • Home
  • 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 764827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:47:30+00:00 2026-05-14T16:47:30+00:00

My goal is to display the same icon twice, but each time in different

  • 0

My goal is to display the same icon twice, but each time in different size. I tried the following:

FileStream fs = new FileStream("name_of_the_icon_file.ico", FileMode.Open);
Icon ico = new Icon(fs, 32, 32);     //create an in-memory instance of the icon, size 32x32
Icon ico2 = new Icon(fs, 16, 16);   //create an in-memory instance of the icon, size 16x16  
...
Graphics.DrawIcon(ico, /*some point*/);
Graphics.DrawIcon(ico2, /*some other point*/);

The last line throws an ArgumentException: Value does not fall within the expected range.
Can some one explain me whats wrong and whats the way to do this right?

  • 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-14T16:47:31+00:00Added an answer on May 14, 2026 at 4:47 pm

    An icon file contains one or more images of different sizes.

    The Icon constructor you are using tries to find an exact match for the size you have given in the icon file. If the icon file does not contain a 16×16 image, it will throw an exception as it can’t match that exact size.

    Instead, just load the icon (without specifying a size, so that all sizes are loaded) and then use the Graphics.DrawIcon(icon, rectangle) override to draw it at the size you wish it to stretch into. It will render using the best-match size defined within the icon (and then scale it if necessary).

    For best quality, edit your icon file (I suggest using IcoFX) to supply specific images at the sizes you want (32×32 and 16×16) so that the icons are not scaled when you draw them.

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

Sidebar

Related Questions

My goal is to display 2 strings in the same cell, one of them
Goal: Display textbox and submit button on the same line in Jquery Mobile. Problem:
My goal is to display two <div> s side-by-side with the content from both
On a Drupal app, my goal is to display a page with a couple
Goal is to make a dialog that appears on menu_key pressed, but it keeps
I have 3 json arrays, each with information listed in the same format: Array:
My website structure is a header, content, footer. My goal is that every time
Goal: Display customized information based on end user's position. If you have 2 user:
Goal: Get the TEXT address and then display the street view and map view
My goal is to achieve a result set like the following CODE | TOTAL1

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.