Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Relocating a Winform - Beginner question

$
0
0

Hello.

I have two Windows Forms in my application - Form1() and Form2(). Form1() is actually never used, I just used it for the context menu. My application is supposed to stay in the tray and it's just fine there.

One of the context menus, does some work and then triggers/calls/opens the Form2() winform. It does its job pretty well, except for the location of Form2(), which doesn't change even after trying 100000 different ways to change it. As we know, the default location is in the top-left, but I want it in the exact opposite: bottom-right.

Here are the ways I tried to relocate Form2():

1. This code is inside a method in Form1():

Form2 linkWindow = new Form2();
linkWindow.Load += (s, ea) =>
{
    var wa = Screen.PrimaryScreen.WorkingArea;
    linkWindow.Location = new Point(wa.Right - linkWindow.Width, wa.Bottom - linkWindow.Height);
    linkWindow.StartPosition = FormStartPosition.WindowsDefaultLocation;
};
linkWindow.toTextBox(responseContent);
linkWindow.Show();

2. I tried changing the location DIRECTLY from the Designer view of Form2() and adding some random coordinates there, it wont relocate.

This is the worst that could happen to a novice like me, I can't even relocate a window.
I can't understand what I am doing wrong.

What could the problem be? Please help.


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>