Is it possible to rotate a picture box without C# code on the Form Designer or change shape of picture box border?
NickName:Scott Ask DateTime:2017-05-10T00:55:29

Is it possible to rotate a picture box without C# code on the Form Designer or change shape of picture box border?

I am very new to C# and WinForms. I am trying to create a segmented display where certain segments turn on and off (Using Microsoft Visual Studio 2015).

Right now I am placing picture boxes with segments I cropped and removed the background on in GIMP and it works fine so long as the segments are far enough away from each other, or are perfectly square.

When they overlap, with setting the picture box background transparent, the picture box is transparent straight through another picture box and just shows the background of the form window where the rectangular picture box is covering.

I tried two different things:

  1. Changing default rectangular shape of picture box to any shape I can draw; not really sure how to do it and i don't think it is possible

  2. Adding a bunch of picture boxes with a dark black picture and then rotating them and moving them to the correct position and turning them on when the particular segment comes on to cover up the problem. However, I don't think I can, or know how to just rotate an entire picture box when I am placing it? I have seen some code online on rotating picture boxes in C# but I am not sure how to implement it. I feel like with anything else there has to be a rotate option I am just missing.

Attached is a picture of the problem, notice how I sent the segment (line) to the back and the SMS quote image to the front. The dotted lines are the picture boxes:

Copyright Notice:Content Author:「Scott」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43875705/is-it-possible-to-rotate-a-picture-box-without-c-sharp-code-on-the-form-designer

Answers
Chris Dunaway 2017-05-09T17:45:27

You can use a WPF project to accomplish what you want. It is much more flexible than WinForms. Plus it supports true transparency. It does have a bit of a learning curve, but if you're just starting out, I think you would be better served to start with WPF.\n\nYou can rotate an Image (PictureBox) in WPF as follows:\n\n<Window x:Class=\"WpfApplication.Window1\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n Title=\"Window1\" Height=\"467\" Width=\"616\">\n <Grid>\n <Image Source=\"C:\\MyFolder\\MyImage.gif\">\n <Image.LayoutTransform>\n <RotateTransform Angle=\"45\" />\n </Image.LayoutTransform>\n </Image>\n </Grid>\n</Window>\n",


More about “Is it possible to rotate a picture box without C# code on the Form Designer or change shape of picture box border?” related questions

Is it possible to rotate a picture box without C# code on the Form Designer or change shape of picture box border?

I am very new to C# and WinForms. I am trying to create a segmented display where certain segments turn on and off (Using Microsoft Visual Studio 2015). Right now I am placing picture boxes with

Show Detail

Change the picture in picture box in C#

I am not sure what is my mistake but i am telling you it works before. I want to change the picture in picture box based on the user's choice. The 1st picture i put is in the picture control box. ...

Show Detail

Is it possible for a picture box to detect colour in another picture box and avoid it?

I am currently attempting to make a visual route planner interface for a local town. The GUI is a map lacking in detail simply showing a green background with grey lines for the roads. Is it possib...

Show Detail

How to rotate image in picture box

I am making a winforms application. One of the features I hope to implement is a rotating gear on the home form. When the home form is loaded, you should hover over the picture of the gear, and it

Show Detail

Using quaternions in Flutter to rotate a picture

I have an accelerometer and gyroscope that I connect to my phone via Bluetooth. I am able to read and store the data that I receive and if I transform the data into eulers I can use the data to rot...

Show Detail

How to put image in a picture box from Bitmap

Is it possible to load a picture from memory (byte[] or stream or Bitmap) without saving it to disk? This is the code I use to turn the byte[] array into a Bitmap: unsafe { fixed (byte* ptr =...

Show Detail

Picture box On Picture Box

This is in regards to C# coding, im quite new to this programming language, and do not know much about any other as well, but what i would like to achieve is to have a picture box as the background...

Show Detail

Picture Box image source is it possible?

Hi I want to set dynamic path to my picture box in winforms. Is it possible to do like this my image is here some thing like http://www.indianorphanages.net/images/india-political-map.gif now I ...

Show Detail

Rotate the inner box as I rotate the outer box

I have two boxes inside a box-wrapper. As I rotate the box, the inner box should also rotate. But, the problem is, the inner box doesn't rotate. Note: I have to make both boxes be position:absolu...

Show Detail

Only CSS rotate box-shadow without original element

I have a small problem, I want to create 45 degree shadow for a picture. But if I use my code my object is rotating too. So I would like to ask for help with this problem. My code: .item { ...

Show Detail