Hi everyone!, and one question about drawing coordinates

matty3269

New member
Joined
Aug 6, 2006
Messages
3
Programming Experience
1-3
Hi everyone,

My first post here and would just like to say hello!

I also have a question...

Is it possible to define a grid to draw on in VB.NET?

A grid that would have an Origin (0,0) in the center of the forum, a bit like a graphing application?

Many thanks
Matt :)
 
It's a little unclear what you mean. You can draw on a control using GDI+. You can draw a grid on a control and you can draw basically anything else as well. If you want to define your own coordinate system then you'd need to perform the translation from the control's client coordinates, which place the origin at the top, left corner and increase to the right and down. If that doesn't answer your question can you provide a little more detail?
 
Yep, I mean to change the client co-ordinates of the forum, so if I was to create a rectangle with co-ordinates (0,0) then it would appear at the center of the forum and then another at something like (200,-200) then it would appear at the top left (assuming that the form is 400x400).

Thanks,
Matt
 
You would need to write four methods: one to translate from form coordinates to your own coordinates, one to translate back again, one to translate an offset from form coordinates to your own and one to translate back. The maths is very simple and you just have to use the Width and Height properties of the form, e.g.
VB.NET:
Public Function FormCoordiantesToCustom(ByVal pt As Point) As Point
    Return New Point(pt.X - Me.Width \ 2, pt.Y - Me.Height \ 2)
End Function
 
Back
Top