1

I have been designing a simple powerpoint/image-editor style program.

I have a panel in my program where I can drag and drop in multiple images and textboxes, resize and move these items.

The problem I am having is that I want to be able to place multiple images on the panel and these may overlap, so at the minute I get all the excess whitespace because of the picturebox even when the png or bitmap has no whitespace, its the filler whitespace between the image and the picturebox.

Hope that makes sense

I have posted an image which shows the problem.

enter image description here

Can anyone see a solution to this problem?

kev3kev3
  • 395
  • 1
  • 6
  • 21
  • 1
    Is your Image type of `GIF` or `PNG` which supports transparent color so that only the image is displayed without background around? – King King Jul 15 '13 at 08:56
  • If you are doing custom drawing and multiple images then I would recommend using a `Panel` rather than a `PictureBox` – musefan Jul 15 '13 at 09:01
  • Hi Both. King King, I am using PNGs so if I was to put the above images into paint.net for example, they would have transparent backgrounds and no white space. musefan, so just use panels and set the background image? – kev3kev3 Jul 15 '13 at 09:18

1 Answers1

0

You should try to override the OnPaintBackground-method, as shown here:

https://stackoverflow.com/a/8689454/2549398

Community
  • 1
  • 1
officer
  • 2,080
  • 1
  • 20
  • 29
  • Hi, I will give this a try. I take it I would implement these override methods on the panel on which I am dragging the pictireboxes onto? – kev3kev3 Jul 15 '13 at 09:57
  • Sorry, was busy yesterday. Did you manage to solve the problem? – officer Jul 17 '13 at 06:22
  • Hi, I haven't yet as yesterday I started playing about with WPF, but trying to translate what I have already done in WinForms to WPF has proved troublesome. So I am going to go back to my WinForms and try what you have suggested. So I have a UserControl which consists of a picturebox and has several event handlers attached to do various things. Do I override the onPaint etc for this user control? As I am working with a bitmap in the picturebox which is added to the picturebox by picturebox.image what do I do where it says //Do your drawing here – kev3kev3 Jul 17 '13 at 08:41
  • Having added the code suggested to my custom picturebox class what was whitespace is now solid black ?? :-S – kev3kev3 Jul 17 '13 at 08:52