Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting button background / image to animated gif
    text
    copied!<p>I have a .gif file which i wish to use as the background image for a button. The main reason i want to do this (as i know some of you will wonder why i want to do it this way) is because, a button relates to an instance of a class, and i want to monitor these classes. when a class (and therefore button) goes into an "alarmed" state, i wish i use these animated gif. i've tried;</p> <pre><code>mainUI.Controls["btn" + device.deviceButtonNumber].BackgroundImage = (System.Drawing.Image)Properties.Resources.red_orange; </code></pre> <p>But it is to my understanding that .BackgroundImage does not support animated gifs. i've tried a few suggestions throughout stackoverflow and non of these seem to work for me, such as setting BackgroundImageLayout to center and such.</p> <p>I suppose as a last resort i could get it to cycle through the images manually as if it were a gif, but this would create more work and i'd like to keep things simple. Any suggestions?</p> <p>edit: sorry, forgot to add, this is in Winforms.</p> <p>edit 2:</p> <p>for example. when i create my buttons dynamically, like so;</p> <pre><code> Button btnAdd = new Button(); btnAdd.Text = mDevices[i].deviceDescription; btnAdd.Location = new Point(mDevices[i].deviceXPos.Value, mDevices[i].deviceYPos.Value); </code></pre> <p>I can still access:</p> <pre><code> btnAdd.Image &lt;- note i can access image. </code></pre> <p>then when i come to modify them later from another thread, i find them like so;</p> <pre><code> mainUI.Controls["btn" + device.deviceButtonNumber].text = blah blah mainUI.Controls["btn" + device.deviceButtonNumber].Location = blah blah </code></pre> <p>however i CANNOT access;</p> <pre><code> mainUI.Controls["btn" + device.deviceButtonNumber].Image </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload