views:

149

answers:

2

How does one find the coordinates halfway on the X and Y axis in a user control or form?

How can I identify the range of the X-axis and the Range of the Y axis on a user control or form?

+1  A: 

You are probably looking for the ClientRectangle property.

To find the range: do you mean the range on screen? if so, use the RectangleToScreen function.

To find the middle point, you can use

Rectangle r = this.ClientRectangle;
Point p = new Point(
  (int)((r.X + r.Width) / 2),
  (int)((r.Y + r.Height) / 2));
Paolo Tedesco
Could this be used to find the range of the X-Y Axis or halfway point on either?
stormist
It's not very clear what you mean by 'axis', maybe you should clarify that a little.
Paolo Tedesco
+1  A: 

What does axis mean in your context?

Given the Height and Width properties, you should be able to work out the halfway position (remembering that Y is positive downwards!)

If, however, you are implementing axes in your own units, you will want to create some helper functions to convert from your units to pixels (and back, potentially)

Benjol