0

I pretty much just started using Windows forms and I'm trying to add a picture to a picture box. First I tried the most obvious way, that is - clicking on the little arrow in the top right corner of a picturebox and clicking "choose image" in the small dialog box, but no matter what I do, the "choose image" button does utterly nothing. I know it should open some dialog box where I could choose my picture, but litterally nothing happens, not even an error message pops up.

Next I tried importing the picture through the properties of the picturebox, but after clicking on the three dots next to the image property an error message pops up, saying "value cannot be NULL, Name o parameter: docData".

I tried following this answer (How to attach a resource (an image for example) with the exe file?) and going to the properties of my project and then to the resources tab, but I have this tab completely empty, saying just that my project does not contain any default resources and a "click to create them" button. However when I click it, another error message appears saying "system cannot find the file. Exception based on value HRESULT:0x80070002"

I guess the problem must be somewhere in my resources file (which might be missing or whatever), but I have a default .resx file there that I haven't touched since the creation of this project which I had thought should be fine.

Afterall I pretty much just started with WinForms and I don't have much clue what's going on and this is quite a significant setback for me. I would be grateful for any help.

  • 1
    Sound like you either have a corrupt project, or possibly Visual Studio. Try creating a new, blank WinForms project with nothing but a PictureBox, then try setting the `Image` property in the Properties Pane. If that doesn't work, I'd start with a repair/re-install of Visual Studio. – Idle_Mind Oct 28 '20 at 13:13
  • My visual studio had a small update, so I updated it and then let it repair itself through the VS installer, however it still makes the same errors and problems and I'm not sure, if reinstalling it would help, since the repair pretty much already resetted everything to default settings – Vit Zelezny Oct 28 '20 at 14:44
  • So, I've done some research and found these posts (the second one with link to another post): https://developercommunity.visualstudio.com/content/problem/866598/cant-input-an-image-to-picturebox.html https://stackoverflow.com/questions/20997710/adding-an-image-in-a-picture-box-windows-form However none of them seem to help, the first one suggested it's caused by missing Properties folder, but I have mine generated since the creation of my Project. Next I tried to load the image using code (as in the second post) and this actualy work, so I guess, I'll have to load everything like this. – Vit Zelezny Oct 28 '20 at 15:28
  • Does it behave the same way with a new, blank project? – Idle_Mind Oct 28 '20 at 16:37
  • Yes, I tried creating a few new projects, no matter what I do, it does not work. I've been currently working around it by loading the images from files (Image.FromFile(path...)), but it is quite tedious – Vit Zelezny Oct 28 '20 at 18:57
  • Sorry, my friend. That is definitely not the way it should be behaving. Still recommend a complete re-install, but I know how much of a pain that can be. – Idle_Mind Oct 28 '20 at 18:59
  • You've added a Resource Image to the Project's Resources, then moved or deleted the file (probably from the Resources folder). Don't do that. – Jimi Oct 28 '20 at 19:17

0 Answers0