Can't resize with ResizeDraw

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 131
Reputation: degamer106 is an unknown quantity at this point 
Solved Threads: 0
degamer106 degamer106 is offline Offline
Junior Poster

Can't resize with ResizeDraw

 
0
  #1
Sep 21st, 2008
Hi,

In on of the lecture notes that was given to me by my prof, I was told that setting the ResizeRedraw value to true would allow whatever I drew on the form to be, well, resized. However, it does not seem to work. Here is my code:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace Test1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. private Rectangle m_Rect;
  15.  
  16. public Form1()
  17. {
  18. Point p = new Point(ClientRectangle.Width / 2 - 100 / 2,
  19. ClientRectangle.Height / 2 - 100 / 2);
  20. Size s = new Size(100, 100);
  21. m_Rect = new Rectangle(p, s);
  22.  
  23.  
  24. InitializeComponent();
  25. ResizeRedraw = true;
  26. }
  27.  
  28. private void Form1_Paint(object sender, PaintEventArgs e)
  29. {
  30. Brush b = new SolidBrush(Color.Red);
  31. Pen pen = new Pen(new SolidBrush(Color.Black));
  32.  
  33. e.Graphics.DrawRectangle(pen, m_Rect);
  34. e.Graphics.FillRectangle(b, m_Rect);
  35. }
  36. }
  37. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Can't resize with ResizeDraw

 
0
  #2
Sep 22nd, 2008
ResizeRedraw does not resize anything, it just tells the control to redraw if its size is changed.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 131
Reputation: degamer106 is an unknown quantity at this point 
Solved Threads: 0
degamer106 degamer106 is offline Offline
Junior Poster

Re: Can't resize with ResizeDraw

 
0
  #3
Sep 22nd, 2008
Ok, ty. Now, how do I make the syntax work? It's not doing what it's supposed to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Can't resize with ResizeDraw

 
0
  #4
Sep 22nd, 2008
its not clear whats not working, it most likely is working as the code you showed looked to be compilable, and the redraw would tell the component to redraw if it were resized..
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 131
Reputation: degamer106 is an unknown quantity at this point 
Solved Threads: 0
degamer106 degamer106 is offline Offline
Junior Poster

Re: Can't resize with ResizeDraw

 
0
  #5
Sep 22nd, 2008
Originally Posted by LizR View Post
its not clear whats not working, it most likely is working as the code you showed looked to be compilable, and the redraw would tell the component to redraw if it were resized..
Well, the code does compile. It's just that when I maximize or minimize the window or drag the sides of the window and let go, the rectangle, which is centered, doesn't get redrawn. I don't know if it has to do with the ResizeRedraw = true; statement being in the constructor but according to my professor, it's supposed to work. Strangely enough, the resizing works when I place all the statements in the constructor to build the Rectangle in the Form1_Paint() method. Problem is, I don't understand why that is and why it isn't working when those statements are in the constructor.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Can't resize with ResizeDraw

 
0
  #6
Sep 22nd, 2008
Possibly because the components arent initialized by that point, try it in the form load event.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC