CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Deploying Windows Server 2008 with System Center
  • Remote Desktop Protocol Performance Improvements in Windows Server 2008 R2 and Windows 7
  • The Microsoft Dynamics CRM Security Model
  • SQL Server Modeling Services with Microsoft Visual Studio 2010 Beta 2

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C-Sharp Programming Post questions, answers, and comments about C#.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 21st, 2009, 10:50 AM
    invader7 invader7 is offline
    Member
     
    Join Date: Jun 2009
    Posts: 96
    invader7 is on a distinguished road (10+)
    How to check if a picturebox is empty

    I can't figure out how to check if a picturebox is empty, i tried
    Code:
     if (picturebox.image != null) {}
    but it dosn't work, is there a way to check it ? thanks
    Reply With Quote
      #2    
    Old November 21st, 2009, 07:25 PM
    BigEd781 BigEd781 is offline
    Senior Member
     
    Join Date: Jun 2008
    Posts: 1,194
    BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+)
    Re: How to check if a picturebox is empty

    What do you mean it doesn't work? If you mean that it doesn't compile you are correct; there is not 'image' property, C# is case sensitive, the property name is 'Image', and it certainly does work to check if there is bot image assigned.
    Reply With Quote
      #3    
    Old November 21st, 2009, 08:11 PM
    invader7 invader7 is offline
    Member
     
    Join Date: Jun 2009
    Posts: 96
    invader7 is on a distinguished road (10+)
    Re: How to check if a picturebox is empty

    yes i know about case sensitive i wrote it correct to my program, it compiles but if there is an image it doesn't execute the code of if statement as it shoud.
    Reply With Quote
      #4    
    Old November 21st, 2009, 08:57 PM
    BigEd781 BigEd781 is offline
    Senior Member
     
    Join Date: Jun 2008
    Posts: 1,194
    BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+)
    Re: How to check if a picturebox is empty

    Quote:
    Originally Posted by invader7 View Post
    but if there is an image it doesn't execute the code of if statement as it shoud.
    Of course that is what happens, because if there is an image present "Image" will never be null, how could it? It is like assigning '10' to a variable and then wondering why it does not equal '9'. Well, it's because you set it to 10!
    Reply With Quote
      #5    
    Old November 21st, 2009, 09:11 PM
    invader7 invader7 is offline
    Member
     
    Join Date: Jun 2009
    Posts: 96
    invader7 is on a distinguished road (10+)
    Re: How to check if a picturebox is empty

    ok i just found a solution, i have a global variable and when i assign an image to picturebox i give my variable the value 1 and when needed i check if variable is 1, if yes dispose if not do nothing...

    Last edited by invader7; November 21st, 2009 at 09:44 PM.
    Reply With Quote
      #6    
    Old November 21st, 2009, 09:55 PM
    BigEd781 BigEd781 is offline
    Senior Member
     
    Join Date: Jun 2008
    Posts: 1,194
    BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+) BigEd781 is a glorious beacon of light (400+)
    Re: How to check if a picturebox is empty

    No... that is a bad solution. You don't need to reference count in C#.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:11 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.