Muhammad Atif Agha
Muhammad Atif Agha

Reputation: 1545

Windows Forms C# Panel should not have white background, and panel should be only image

I have a windows forms, i have placed an image on it, and the image is not rectangular, so white space lefts with it, because windows form is either square or rectangular, but image is not, i want panel should be only image, rest of the space should not be visible, i am attaching an image to describe further.

Thanks Atifenter image description here

Upvotes: 2

Views: 1406

Answers (6)

Krishna
Krishna

Reputation: 680

Read the ImageSize before applying to the form. Resize the form with the image size. If you can set the ControlBox property of the Form, you can even hide the Close, Maximize and Minimize buttons from the right top corner.

Upvotes: 1

Nahum
Nahum

Reputation: 7197

as I understand it you want your form to be invisible? that isn't supported well in winforms and you should consider moving to WPF. however theres this example:

http://www.blackbeltcoder.com/Articles/winforms/non-rectangular-splash-screen-for-winforms

create a splash screen as the writer advices.

Upvotes: 3

Baskaran
Baskaran

Reputation: 283

I think you have set form properties [BackgroundImageLayout:stretch] or

you have to change image size(width,height) same as form size(width,height)

Upvotes: 1

Hand-E-Food
Hand-E-Food

Reputation: 12794

Put the image on the form directly by setting the following properties:

Form1.BackgroundImage = MyBackgroundImage
Form1.BackgroundImageLayout = Stretch

Upvotes: 0

Charles Graham
Charles Graham

Reputation: 1157

You need to set the BackgroundImageLayout property to ImageLayout.Stretch, ImageLayout.Zoom or ImageLayout.Tile depending on how you want the image to fill the Form.

Upvotes: 0

Zenwalker
Zenwalker

Reputation: 1919

So you mean to stretch your image to the window frame? Just dock the picturebox to full form size. There is an option called Dock in parent container. Use that

Upvotes: 0

Related Questions