CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Posts
    5

    Question 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!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: CSharp Basic Function help.

    Need to Invalidate the main control to force a redraw
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2009
    Posts
    5

    Smile 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
  •  





Click Here to Expand Forum to Full Width

Featured