Click here to Skip to main content
15,905,071 members
Everything / Rectangle

Rectangle

rectangle

Great Reads

by Richard James Moss
This article describes how to break up a rectangle into smaller parts based on user defined co-ordinates.
by Dwain Snickles
Add Cropping to any control with image or backgroundimage

Latest Articles

by Dwain Snickles
Add Cropping to any control with image or backgroundimage
by Richard James Moss
This article describes how to break up a rectangle into smaller parts based on user defined co-ordinates.

All Articles

Sort by Score

Rectangle 

16 Aug 2013 by Clifford Nelson
WPF does not use decimal as far as I know for any internal values. Many times have to be careful about even using double since there are other properties that are used, like Size or Thickness.
31 Aug 2017 by RickZeeland
In addition to the nice article mentioned by Graeme (which deserves points really) Making Transparent Controls - No Flickering[^] , the following: If you want to "punch a hole", this article might be of interest: Phil Wright : Component Factory: .NET2, Transparent controls[^] Also using...
18 Feb 2013 by Richard James Moss
This article describes how to break up a rectangle into smaller parts based on user defined co-ordinates.
27 Apr 2013 by Autumn_Gao
thank you all, i have solved it myself, just one simple mistake. i forgot to import namespace Gdiplus, when addusing namespace Gdiplus, problem solved
3 Aug 2018 by Richard MacCutchan
If you draw objects outside of the function that responds to the WM_PAINT message, then it will not work. As soon as the dialog is shown it will erase the background and redraw all controls in the resource. You should add the rectangle into your resource settings.
23 May 2019 by Richard MacCutchan
You should do all your painting/drawing to the screen in the function that handles the WM_PAINT message. Each time this function is called it should redraw all the shapes. When a shape is deleted you just remove it from the list of items to draw, and then call InvalidateRect to force a repaint...
18 Sep 2022 by Richard MacCutchan
Quote: It is really at the expense of my grade. In that case it is important that you do the work, so that your grade is based on your skill set and not someone else's.
18 Sep 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
N 20 May 2024 by Jo_vb.net
Binding DG1 to DG2 makes no sense. Use ResourceDictionary ResourceDictionary and XAML resource references - Windows apps | Microsoft Learn[^] or create a DataGrid Usercontrol as template for your DataGrids.
2 Mar 2013 by qasimqadri
this is my below code which draw rectangle and eclipse on mouse event..i try search undo alots.but fail to undo mycode..i want dat wen i click on button then last rectangle remove from drawing.pls dnt give me link.modify my code coz am not very much experience on graphics.simply click button...
2 Mar 2013 by OriginalGriff
Since you add your objects to a list (or two) here is how I would do it.1) Create an abstract MyShape class, and derive a MyRectangle and MyOval from it. Probably, each should provide code to draw themselves, given an appropriate Graphics object2) Replace my two lists with a single MyShape...
28 Mar 2013 by kastriotlimani
Hi, i am a beginner at coding, and i am making a little game where a character is capturing some dots generated randomly.Now i need each dot to be an image (same image for all), but i cant find out how to do it.This is a piece of what I did:Rectangle[] rects;rects = new...
16 Jun 2013 by Mohamed Sayed
i need your help for adding Rectangle,Circle and Ellipse options to my mini-paint app project,but i need all this on mouse event, i searched every where but most of sites give specific dimensions so I'm failed to get rectangle option to work :(i add save option to save the drawn pic to bmp...
14 Aug 2013 by Shahare
It appears I just had to turn the binding property and the converter to double instead of decimal.
27 Feb 2014 by DROB08
I have been trying to calculate the right side of my rectangle so that it avoids mouse going over a specific area within a picture box. This works fine when zoom factor is on, after zoom is increased right side becomes smaller than the Picturebox's width hence I can not move the mouse over the...
13 Jun 2014 by Pixel86
How to find the given rectangle co-ordinates are overlapped ?How to group it together one if rectangles are overlapped?Here given example Exmaple:Format - Rect.x , Rect.y Rect.Width , Rect.HeightvectorboundRect(8);boundRect[0].x = 260; boundRect[0].y = 77; ...
13 May 2014 by CPallini
Finding if two rectangles overlap is not that dramatically difficult, namely if (((r0.x0 r1.x0) || ( r1.x0 r0.x0 )) && (r0.y0 r1.y0) || ( r1.y0 r0.y0 ))) { // overlap }You may use >= and
13 May 2014 by Richard MacCutchan
You would need to write a function that does the comparisons, and returns a true or false result. If you are using Windows then you can make use of the IntersectRect function[^]
10 Oct 2014 by loraloper_22
hii have four coordinates which correspond to (x,y,width,height) . I can draw a rectangle over an image from this script but it is a filled rectangle with redcolor i want a a bounding box or a transparent rectangle I=imread('000027.jpg');figure,imshow(I)hold...
10 Oct 2014 by loraloper_22
I=imread('000027.jpg');imsho...
24 Mar 2015 by Member 10455358
I have been trying and trying to add a filled rectangle to a FlowLayoutPanel so that its behind the buttons im creating in the FlowLayoutPanel via a loop. But I cant get it to work. The program creates 1 button at a time from an access database. I need it to draw a rectangle behind the button it...
24 Mar 2015 by Sergey Alexandrovich Kryukov
"Filled rectangle" is not a control. Simply wrap it in a control. Create a custom control and render whatever you want on it. (Alternatively, use PictureBox with image showing a rectangle. Don't do it if you image is supposed to be dynamic, in any sense.) Please see my past answers:Append a...
25 Mar 2015 by Member 10455358
Thanks for your input - I have tried the picturebox and it half works but it puts the buttons beside the picturebox and it needs to be over it so that the picturebox becomes the background for the button. This is needed to allow me to load transparent background images into the button while...
6 Jun 2015 by DrgIonuţ
I have a server-client application, but my task now is to fill a square of a rectangle when I click it. How can I do this?using System;using System.Windows.Forms;using System.Text;using System.Net.Sockets;using System.Threading;using System.IO;using System.Collections;using...
5 Jun 2015 by Sergey Alexandrovich Kryukov
Your problem is not filling something which was previously drawn with the lines. As I can see, you know how to use FillRectangle. Your problem is different. I can see the fragments of code where you do drawing on click or some other events. The problem is: what you draw this way is not backed...
7 Jun 2015 by Ralf Meier
This sample-code will show you what I have described :Writing your Custom Control: step by step[^]
25 Jun 2015 by ParniM
Hi everybody,I just want to get a clicked element name in the ViewModel code.Basically, I generate several rectangles programmatically ...
14 Dec 2016 by Sruthi Suresh
AM drawing multiple rectangles in my windows form and is saved to a rectangle list at run time.how do i move these rectangles with mouse and then save it to the rectangle list at run time so that the user can place these rectangles as they wishWhat I have tried:i tried to locate the...
14 Dec 2016 by CPallini
"It didn't worked" is not pretty informative. Please elaborate.Anyway, I suppose you are missing a conversion from Screen to Client coordinates (or the opposite). Have a loook at Mouse Events in Windows Forms[^] and at Control.PointToClient Method (Point) (System.Windows.Forms)[^] (for sample...
14 Dec 2016 by Ralf Meier
to complete the Solution from CPallini a Little bit :If you do a MouseDown on your Form you have to look it the actual MousePosition is at a coordinate-range of one of your rectangles.If Yes you should memorize the actual MousePosition relative to the Rectangle-Postion.If you now move...
1 Sep 2017 by newbie1992
hello morning everyone anyone know how to crop (make a rectangular hole in) a control? i try to crop a square in the middle of the panel for an example if the size of my panel was Panel myPanel = new Panel() { Size = new Size(300, 800), Location = new Point(0,0); BackColor =...
3 Sep 2017 by BillWoodruff
using System.Drawing; using System.Windows.Forms; namespace PathStuff { public static class PathExtensions { public static void MakeHole(this Control cntrl, Rectangle xrect) { var region = new Region(cntrl.ClientRectangle); region.Exclude(xrect);...
14 Dec 2017 by CPallini
Such code works, actually. Create an empty Windows Form project, add the on paint event handler and modify it this way: private void Form1_Paint(object sender, PaintEventArgs e) { DrawRectangleRectangle(e); }
3 Aug 2018 by Member 12533122
Hello people. I am drawing rect in my application on button click. but i want draw it on start of application. as i am drawing on OninitDialog function it will not drawing anything on it. so how can i draw it on starting application? What I have tried: void XYZ::OnBnClickedOk() { CRect rc;...
3 Aug 2018 by KarstenK
Another solution is to use PostMessage for a WM_PAINT message which triggers the painting of your control. Best is to use InvalidateRect for the control before. Tip: Create the pens only once, as class members or as static objects to improve performance.
23 May 2019 by Member 14430889
Dear All: i am new, i just start to learn draw shape with vs2012 c++ and Gdiplus about 5 weeks, i create a simple project to test, but when i draw polygon finish, i cannot delete any polygon which i selected from canvas, it not so easy like to delete a rectangle or a ellipse, only delete the...
22 Jun 2023 by Rasini K
How to position a rectangle control with signature area, on bottom part of last page of rdlc report vVisual studio 2019. What I have tried: I tried to put the rectangle inside the Page footer and gave expression for visibility. If last page,...
U 20 May 2024 by Sh.H.
Hi people. I have a two DataGrids. Both have a column with Shape of Rectangle, I mean all cells have Rectangle with same attributes. How may I bind the Fill and the Height of Rectangles in DataGrid1 to Rectangles of DataGrid2 in WPF ? Thanks ...
27 Apr 2013 by Jochen Arndt
You probably wanted to use the CRect class.Note that all MFC class names begin with an uppercase 'C' letter.
31 Aug 2017 by Graeme_Grant
[moved from comments - thanks for the suggestion RickZeeland] Is the hole suppose to show objects behind it? Like a transparent hole? Something like this: Making Transparent Controls - No Flickering[^][^]???
14 Aug 2013 by Shahare
Hi allI have a piece of code sample which suppose to set the width of the rectangle from a converter. I can see the converter is called twice (the second time with the required value) but the value does not seem to reach the Width property of the rectangle.note: I use rectangle on...
3 Oct 2022 by Dwain Snickles
Add Cropping to any control with image or backgroundimage
17 Jun 2013 by Chris Ross 2
To draw items like rectangles, circles, etc. you need to first think about how you want your user to interact with the program when the are adding a rectangle, etc. For example - mouse down, drag, up might record one corner (mouse down position) and then the opposite corner (mouse up). A circle...
28 Mar 2013 by johannesnestler
assuming your code is working - just change the scG.FillRectangles to (a looped) call to scg.DrawImage ...
27 Apr 2013 by Autumn_Gao
i used Rect Class in my MFC project under vs2010 like this: Rect m_rectand include , but still got this error: Error:identifier "Rect" is undifinedis there anyone who can tell me why?
14 Dec 2017 by Member 13576087
What should i write to inicialize a program to draw shapes and lines on the screen ? I have tried some code, but it fails. Not working ... (for while, i just can code to make simple things as console input and output/Console.ReadLine, Console.WriteLine ...) Thank you/Regards Carlos What I...
18 Sep 2022 by Member 15771187
Identical rectangles We will be writing a program to determine whether two rectangles are of identical dimensions. Looking at the example above, you can see that the rectangles do indeed seem to be identical. We can check this better if we have...