c# - How to place one form just above another in winforms? -


im creating winforms application notified every , of messages or occurrences. notification style i'm expecting of gtalk, if user sends message shows notification on bottom right of screen, , if there message user @ same time new notification window shown above previous one. new window wont overlap or eclipse older one.

so far have achieved few things

getting window on bottom right of screen wasnt big task using code in constructor

    rectangle workingarea = screen.getworkingarea(this);     this.location = new point(workingarea.right - size.width, workingarea.bottom - size.height); 

but once form named "notify" opened @ bottom right of screen. when new notification comes overlaps previous form. there can that. missing obvious?

this parent form button, creates new notification forms:

public partial class parent_form : form {     public static list<form> activenotifications = new list<form>();      public parent_form()     {         initializecomponent();     }      private void button1_click(object sender, eventargs e)     {         notification notification = new notification();         activenotifications.add(notification);         notification.show();     }      public static void sortnotifications()     {         int additionalheight = 0;         foreach (form notification in activenotifications)         {             notification.location = new point(0, (0 + additionalheight));             additionalheight += notification.height;         }     }      public static point getlocation()     {         int height = 0;         foreach (form notification in parent_form.activenotifications) { height += notification.height; }         return new point(0, height);     } } 

the parent form contains button1, used create new notifications

this notification form example:

public partial class notification : form {     public notification()     {         initializecomponent();         this.location = parent_form.getlocation();         this.formclosing += notification_formclosing;     }      private void button1_click(object sender, eventargs e) { this.close(); }      private void notification_formclosing(object sender, formclosingeventargs e)     {         parent_form.activenotifications.remove(this);         parent_form.sortnotifications();     } } 

notification includes button1, used close notification form. make sure notification form uses startposition "manual".


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -