| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| C-Sharp Programming Post questions, answers, and comments about C#. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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) {}
|
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
Re: How to check if a picturebox is empty
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!
|
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
Re: How to check if a picturebox is empty
No... that is a bad solution. You don't need to reference count in C#.
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|