[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Rectangle in Windows forms

Posted on 2010-11-22
11
Medium Priority
?
972 Views
Last Modified: 2012-06-21
Hello
I want to paint a Rectangle in my Windows Form. I know the object Rectangle, which can be generated at runtime.
But how can I paint a Rectangle in the Designmode on my form (drag it from the toolbox) like other controls (f.e. button)
Is there a way to do this?
I work with VS 2010.
0
Comment
Question by:ICSAutomation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
11 Comments
 
LVL 4

Expert Comment

by:EmuL8_sw
ID: 34194568
Hi,

In the Toolbox just go to "Visual Basic PowerPacks"

There are a few shapes there

Hope this helps
0
 
LVL 1

Assisted Solution

by:webbphil
webbphil earned 150 total points
ID: 34194576
There are two ways todo this.   Easiest method would be to add a panel control to the form and set the BorderStyle property to FixedSingle and set the BackColor property.  That will give you a rectangle with a black border and a background of your choice.

If you are looking for more flexible functionality, you can create a new custom control that inherits from the panel and add your own or override existing properties, events etc.

Take a look here:

Developing Windows Forms Controls at Design Time
http://msdn.microsoft.com/en-us/library/w29y3h59(v=VS.100).aspx

Walkthrough: Inheriting from a Windows Forms Control with Visual C#
http://msdn.microsoft.com/en-us/library/5h0k2e6x(v=VS.100).aspx
0
 
LVL 3

Expert Comment

by:abdkhlaif
ID: 34194580
you can add a Panel control and change its BackColor
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ICSAutomation
ID: 34194632
>> In the Toolbox just go to "Visual Basic PowerPacks"
Sorry, I forgot to mention that I Work with C#

I already created a UserContorl, inheritated from a Panel. But I also would like to have round corner, and there I don't know how to programm it.

0
 
LVL 4

Expert Comment

by:EmuL8_sw
ID: 34194665
You can use the Visual Basic Power pack in a C# Forms Application and you can set its corner radius as well.

So it will then have rounded corners
0
 
LVL 3

Expert Comment

by:abdkhlaif
ID: 34194696
use PictureBox control
0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 150 total points
ID: 34194783
Try this code.

Rectangle rect = new Rectangle(0,0,this.Width,this.Height);
GraphicsPath path = Helper.GetRoundedRectPath(rect, 7);
this.Region =new Region(path);
foreach(Control C in panel1.Controls)
{
if(C.GetType().ToString() == "System.Windows.Forms.Button")
{
rect = new Rectangle(0,0,C.Width,C.Height);
path = Helper.GetRoundedRectPath(rect,4);
C.Region = new Region(path);
}
}
0
 

Author Comment

by:ICSAutomation
ID: 34195959
@samirbhogayta:
I'm lookin gfor a Contorl that I can pull from the toolbox

@abdkhlaif:
I can't make round corners in a PictureBox

@EmuL8_sw:
I don't want to install the Visual Basic Power pack
0
 
LVL 4

Expert Comment

by:EmuL8_sw
ID: 34195976
Sorry, I though Visual Studio 2010 comes standard with the Power Pack... Mine had it included and I didn't install any additional components/packs
0
 
LVL 3

Accepted Solution

by:
abdkhlaif earned 450 total points
ID: 34197159
you can create an image with round corners then load it using a PictureBox control
in fact, you can create any shape (image) and display it on the form with PictureBox
0
 

Author Closing Comment

by:ICSAutomation
ID: 34205457
Is not exactly what I need, but I can us this solution aswell
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question