|
-
May 10th, 2009, 03:54 PM
#1
CSharp Basic Function help.
Hi,
I am building/programming a freeware app in CSharp, and I am dealing with graphic "Click" functions.
I am using CSharp express 2008 (microsoft), and rather than create a "click" function for each graphic, I decided to make a function to call (this may actually slow it down, but it seems much easier to handle.).
right now there are about 4 of these -
Code:
private void pictureBox5_Click(object sender, EventArgs e)
{
if (pictureBox5.BackgroundImage != pictureBox33.Image)
{
pictureBox5.BackgroundImage = pictureBox33.Image;
}
else
{
pictureBox5.BackgroundImage = pictureBox29.Image;
}
}
What I did was write this -
Code:
public void Funky(System.Drawing.Image strParam)
{
if (strParam != pictureBox33.Image)
{ strParam = pictureBox33.Image; }
else
{ strParam = pictureBox29.Image; }
}
and call it like this -
Code:
private void pictureBox13_Click(object sender, EventArgs e)
{
Funky(pictureBox13.BackgroundImage);
}
What I'd like to have happen is to have the resource be changed out, but I am thinking I am identifying it wrong, or need to convert the variable. I am new to CSharp, but experienced in other languages. Any help appreciated!
-
May 10th, 2009, 08:13 PM
#2
Re: CSharp Basic Function help.
Need to Invalidate the main control to force a redraw
-
May 11th, 2009, 12:39 AM
#3
Re: CSharp Basic Function help.
Thank you much for the response.
Got it working great.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|