Hi,
I am overriding the method given to draw ellipses on my window,
using the following code. My problem is that I have a button that
every time it is pressed, a variable is inremented, indicating that a
new ellipse is to be drawn. What should I do to refresh the window to
draw the new ellipse.
Thanks in Advance
private void Form1_Load(object sender, System.EventArgs e)
{
tot=1;
}
protected override void OnPaint(PaintEventArgs pe)
{
Graphics g = pe.Graphics ;
Pen pn = new Pen( Color.Crimson);
Rectangle rect;
for (int x=0; x<tot; x++)
{
rect= new Rectangle (25,(80*x)+5,40,40);
g.DrawEllipse( pn, rect );
} // end for loop
}
private void button1_Click(object sender, System.EventArgs e)
{
tot++;
} 3 9446
Xarky,
You should call the Invalidate method on your control to indicate that
it should be repainted. You can do this after you set the variables when
the button is clicked.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Xarky" <be*********@yahoo.com> wrote in message
news:bc*************************@posting.google.co m... Hi,
I am overriding the method given to draw ellipses on my window, using the following code. My problem is that I have a button that every time it is pressed, a variable is inremented, indicating that a new ellipse is to be drawn. What should I do to refresh the window to draw the new ellipse.
Thanks in Advance
private void Form1_Load(object sender, System.EventArgs e) { tot=1; }
protected override void OnPaint(PaintEventArgs pe) { Graphics g = pe.Graphics ; Pen pn = new Pen( Color.Crimson); Rectangle rect;
for (int x=0; x<tot; x++) { rect= new Rectangle (25,(80*x)+5,40,40); g.DrawEllipse( pn, rect ); } // end for loop }
private void button1_Click(object sender, System.EventArgs e) { tot++; }
Simply call the Refresh() method for your form [this.Refresh()] in your
button click event handler. That will force the form to redraw itself.
Hope this helps.
--
Kai Brinkmann [MSFT]
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Xarky" <be*********@yahoo.com> wrote in message
news:bc*************************@posting.google.co m... Hi,
I am overriding the method given to draw ellipses on my window, using the following code. My problem is that I have a button that every time it is pressed, a variable is inremented, indicating that a new ellipse is to be drawn. What should I do to refresh the window to draw the new ellipse.
Thanks in Advance
private void Form1_Load(object sender, System.EventArgs e) { tot=1; }
protected override void OnPaint(PaintEventArgs pe) { Graphics g = pe.Graphics ; Pen pn = new Pen( Color.Crimson); Rectangle rect;
for (int x=0; x<tot; x++) { rect= new Rectangle (25,(80*x)+5,40,40); g.DrawEllipse( pn, rect ); } // end for loop }
private void button1_Click(object sender, System.EventArgs e) { tot++; }
As told, I did the Refresh method and it worked.
Now I need to add all the ellipses to some type of component having
both the veritcal and horizontal scrollbars. I was thinking of a
RichTextBox, but I have no idea how to add ellipses within the
RichTextBox. Can you give me some help how to do it, or some other
suitable component that I should use.
Thanks in Advance
"Kai Brinkmann [MSFT]" <ka******@online.microsoft.com> wrote in message news:<ej**************@TK2MSFTNGP14.phx.gbl>... Simply call the Refresh() method for your form [this.Refresh()] in your button click event handler. That will force the form to redraw itself.
Hope this helps.
-- Kai Brinkmann [MSFT]
Please do not send e-mail directly to this alias. This alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights.
"Xarky" <be*********@yahoo.com> wrote in message news:bc*************************@posting.google.co m... Hi,
I am overriding the method given to draw ellipses on my window, using the following code. My problem is that I have a button that every time it is pressed, a variable is inremented, indicating that a new ellipse is to be drawn. What should I do to refresh the window to draw the new ellipse.
Thanks in Advance
private void Form1_Load(object sender, System.EventArgs e) { tot=1; }
protected override void OnPaint(PaintEventArgs pe) { Graphics g = pe.Graphics ; Pen pn = new Pen( Color.Crimson); Rectangle rect;
for (int x=0; x<tot; x++) { rect= new Rectangle (25,(80*x)+5,40,40); g.DrawEllipse( pn, rect ); } // end for loop }
private void button1_Click(object sender, System.EventArgs e) { tot++; } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DraguVaso |
last post by:
Hi,
To get faster performance of my DataGrid during scrolling I wanted to build
a timer in the Paint-event that waited some milli-seconds to Paint and
cancelled the method in case it received a...
|
by: Gidi |
last post by:
hi,
i read in the web about how can i change the foreColor of a textBox when
it's set to enabled=false or readonly, and that what was written:
public MyTextBox()
{ // This call is required by...
|
by: bhavin |
last post by:
Hi,
Can someone point me to some good best practices kind of documentation on
use of events compared to method overriding.
Ex. In Windows Forms when should i have an event handler for Paint, and...
|
by: Richard |
last post by:
I have a requirement to put a GDI style circle or rectangle border around
the selected row of a datagrid/ It will overlap into the row above and below
the selected row. Doing this in a the OnPaint...
|
by: James Ramaley |
last post by:
I am trying to modify the way a NumericUpDown control draws itself. I
just need to hide the up/down arrows. I tried overriding both the
OnPaint method and the wm_paint message inside WndProc....
|
by: cok |
last post by:
Hi, all
I have a question about VS 2005 IDE, I donn't know if
It is place to post my question,sorry
I have a class inherit form System.Windows.Forms.Form,
I want to override OnPaint method ,...
|
by: Jon Slaughter |
last post by:
I'm trying to override the toolstripcontainer class to "skin" it and handle
some other things. The problem I'm having is that the container contains the
toolstrippanels
...
|
by: sean |
last post by:
I'm trying to create "rubber-band" rectangles by overriding the
OnPaint method to place rectangles on top of all graphic controls, but
when I call Me.Invalidate() (when the user moves the mouse),...
|
by: =?Utf-8?B?cmFtbzk5NDE=?= |
last post by:
Hi,
Is there any way disable using "protected override void OnPaint(..." method
out of the assembly. I create usercontrol and i do not want user adds extra
codes OnPaint method for securtity...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
| |