Good day to all. I encountered such a problem: when resizing the form, it goes beyond the screen (Left and lower border). So how can you control it and if the form goes beyond the left border then move it to the right and if the form goes beyond the bottom then move it up. For a more detailed description of the problem you can watch the video: Click here.
1 answer
Use Screen.PrimaryScreen.WorkingArea to determine screen sizes.
In the subscriber not the Form_Resize event write:
if (Right > Screen.PrimaryScreen.WorkingArea.Width) Left = Screen.PrimaryScreen.WorkingArea.Width - Width; - That is, if if (Left + Width> Screen.PrimareScreen.WorkingArea.Width) .... change location ....? Do you understand correctly? - Berianidze Luka
- Like that. You tried? - Andrei NOP
- I tried var sc = Screen.GetBounds (this); if (this.Right> sc.Width) {Rectangle r = Screen.FromControl (this) .WorkingArea; this.Location = new Point (this.Right - sc.Width, this.Location.Y); } - Berianidze Luka
- But at the same time the form lags terribly. - Berianidze Luka
- It should look something like this youtu.be/M8n-DRmZLqkhd = 1 - Berianidze Luka
|