15,040,212 members
See more:
I want to share the lines on the page of the windows form. the distance between two successive lines is equal. how i can??.horizontal and vertical lines.thanks
Posted
Updated 27-Dec-13 8:59am
v2
Dave Kreskowiak 27-Dec-13 15:11pm

Share the lines? What on earth does that mean?
Bakhos Sayssouk 27-Dec-13 15:29pm

I want to draw 15 lines vertical and 9 lines horizontal. and the distance between two successive lines is equal.and I want to frame does not start at the beginning because I want to write something in front of each lines down and left.and last lines (vertically and horizontal) coincides with the advantage of the screen.
Bakhos Sayssouk 28-Dec-13 9:03am

I have points to put on windows forms. why I want a meter scale to track x and y. x from 0 to 360 degrees, y from 0 to 90 degrees. meter for the degrees I want a space at the beginning.

## Solution 1

Handle the form Paint event and draw them - you can use the Graphics property of the PaintEventArgs parameter to draw on.
Then:
C#
```Graphics g = e.Graphics;
int spacing = 25;
for (int x = spacing; x < Width; x += spacing)
{
g.DrawLine(Pens.Black, x, 0, x, Height);
}
for (int y = spacing; y < Height; y += spacing)
{
g.DrawLine(Pens.Black, 0, y, Width, y);
}```

## Solution 2

There's drawing lines in the sense of drawing onto the screen by using the Paint Event, and, then, there is drawing lines that are "objects" (vectors), lines that could be clicked-on, moved, etc.

OriginalGriff has shown you how to use the Paint event; for lines-as-objects, you'd could use VB.NET's 'Shape Controls, which are easy to use in C#.

In this case, it sounds like you may be wanting to simulate a kind of a grid into which you will place content, or Controls. If that's correct, then you might want to look at the TableLayoutPanel Control in WinForms (in the 'Containers Tab in the VS ToolBox). That would, however, not give you (easily) the effect of having no left vertical border.

If you say a little more about what you are going to do to/with the lines, how you will use them, you can get more focused advice.

Is it possible that just putting a background image of your grid on a Form, or Panel would meet your needs ? A high-resolution .png graphic with transparency (if you wish) would be very small in size for this type of graphic.

For example, I can create a 1024x768 24-bit .png file with a grid composed of several hundred lines, and save it with transparency, for under 5k bytes in size (in PhotoShop CS6: other drawing programs should give comparable results).