Piotrekk wrote:
Hi
I was wandering if is this possible to resize window in steps
different than 1 px.
Thanks
If you want to limit the user to only being able to size the window in
10 pixel increments, I believe you need to implement this yourself. You
would handle the Resize event, and in there, look at the current Size of
the control that is the sender of the event, then calculate a new Size
as desired, and finally reassign that new Size to the sender.
You'll have to cast the sender to a Control type, of course, so that you
can access the Control class members of the Form.
Something like this might work for you:
private void Form1_Resize(object sender, EventArgs e)
{
Control ctl = (Control)sender;
ctl.Size = new Size(((ctl.Width + 5) / 10) * 10,
((ctl.Height + 5) / 10) * 10);
}
This makes the form restricted to the nearest 10-pixel increment of size
based on the dragging. The "+ 5" before doing the division handles the
rounding; if you just want to truncate to the 10-pixel increment less
than or equal to the dragged size, don't include that part.
Pete