如何将 Windows 窗体打开时放置在屏幕的右下角,而不是左上角?
情况:我有一个Form1,它实际上并没有作为表单做任何事情,我只是将它用于它的上下文菜单(我的应用程序只能从托盘工作)。因此,大部分主要运行代码进入 Form1 类。单击上下文菜单时,它将进行一些处理,最后将显示Form2。因此Form2被Form1的上下文菜单项打开/调用。在这种情况下如何更改 Form2 的位置?
Form1.cs(Form2被触发的部分)
private void menu_upload_file_Click(object sender, EventArgs e)
{
DialogResult dialogOpened = openFileDialog1.ShowDialog();
if (dialogOpened == DialogResult.OK)
{
string filename = openFileDialog1.FileName;
using (var client = new WebClient())
{
var response = client.UploadFile("http://localhost/imgitv3/upload.php?submit=true&action=upload&request=app", "POST", filename);
// string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "response.txt";
if (response != null)
{
string responseContent = System.Text.Encoding.ASCII.GetString(response);
Form2 linkWindow = new Form2();
if (isURL(responseContent))
{
linkWindow.toTextBox(responseContent);
linkWindow.Show();
}
}
}
}
}
Form2.Designer.cs
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(419, 163);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(435, 202);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(435, 202);
this.Name = "Form2";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "IMGit Image Uploader";
this.TopMost = true;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
this.PerformLayout();