[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

patrick

11/23/2004 4:05:00 AM

Hi Ng,

i have a grid which has to be painted on a panel. This panel serves as an
editor to add controls. The grid consists of horizontal and vertical lines,
illustrated with dots (by the way, how can I draw dots, the line shown below
consists of two dots). If I write an algorithm like this

for (int i = 0; i < this.Width; i += this.GridEntity)
for (int j = 0; j < this.Height; j += this.GridEntity)
{
g.DrawLine(blackPen, i, j, i + 1, j + 1);
}

in the OnPaint method, everything is getting terrible slow. It redraws the
grid every time (of course as it is in the OnPaint method), and deletes my
selection rectangles which I use to illustrate the surroundings of the
control while moved.

How can I write this grid much more efficient? Actually it should look like
in the windows form desginer ;-)

Thanks in advance and best regards
Patrick Braunschweig
1 Answer

Bob Powell

11/23/2004 9:49:00 AM

0

Have you tried ControlPaint.DrawGrid?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Patrick" <Patrick@discussions.microsoft.com> wrote in message
news:3425CAA4-5CCC-4A23-84E7-4956199136E7@microsoft.com...
> Hi Ng,
>
> i have a grid which has to be painted on a panel. This panel serves as an
> editor to add controls. The grid consists of horizontal and vertical
lines,
> illustrated with dots (by the way, how can I draw dots, the line shown
below
> consists of two dots). If I write an algorithm like this
>
> for (int i = 0; i < this.Width; i += this.GridEntity)
> for (int j = 0; j < this.Height; j += this.GridEntity)
> {
> g.DrawLine(blackPen, i, j, i + 1, j + 1);
> }
>
> in the OnPaint method, everything is getting terrible slow. It redraws the
> grid every time (of course as it is in the OnPaint method), and deletes my
> selection rectangles which I use to illustrate the surroundings of the
> control while moved.
>
> How can I write this grid much more efficient? Actually it should look
like
> in the windows form desginer ;-)
>
> Thanks in advance and best regards
> Patrick Braunschweig