DEV Community

jpatcharapun
jpatcharapun

Posted on

Answer: How to make my Windows Form app snap to screen edges?

c# form snap to left right top bottom

This worked pretty well, works on multiple monitors, observes the taskbar:

  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
    }
    private const int SnapDist = 100;
    private bool DoSnap(int pos, int edge) {
      int delta = pos - edge;
      return delta > 0 && delta <= SnapDist;

Top comments (0)