Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class opption : Form
{
public opption()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ADD sho = new ADD();



sho.Show();
}

private void button5_Click(object sender, EventArgs e)
{
searchothr sho = new searchothr();

//this.Hide();

sho.Show();
}

private void button2_Click(object sender, EventArgs e)
{
CONTECTINFO sho = new CONTECTINFO();

// this.Hide();

sho.Show();
}

private void button3_Click(object sender, EventArgs e)
{
caseinfo sho = new caseinfo();

// this.Hide();

sho.Show();
}

private void button4_Click(object sender, EventArgs e)
{
timer1.Start();
//if(timer1.Stop
// MessageBox.Show("THANK YOU FOR USING ");

timer1.Stop ();
Application.Exit();
}

private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString("hh:mm:ss tt");
}

private void button6_Click(object sender, EventArgs e)
{
update sho = new update();

//this.Hide();

sho.Show();
}

private void button7_Click(object sender, EventArgs e)
{
remove sho = new remove();

// this.Hide();

sho.Show();
}

private void button8_Click(object sender, EventArgs e)
{
//button8= DateTime.Now.ToString();
}

private void label1_Click(object sender, EventArgs e)
{

}

private void opption_Load(object sender, EventArgs e)
{
label2.Text=DateTime.Now.ToString("d/MM/yyyy");
label1.Text = DateTime.Now.ToString("hh:mm:ss tt");
//label1.Text=DateTime.Now,ToString("dd//mm//yyyy");
timer1.Start();
}
}
}
Posted

hi Use
C#
sho.StartPosition = FormStartPosition.CenterScreen;
or any other options from FormStartPosition enum

refer this link for further details

https://msdn.microsoft.com/en-us/library/system.windows.forms.formstartposition%28v=vs.110%29.aspx[^]
 
Share this answer
 
If forms are modeless, then you don't want them to appears at the same place except if you ensure that only a single form is displayed at a time. In that case, if all forms are the same size, then you can save the location and use that location when any of these forms are displayed.

Solution 1 is another alternative but I would not recommand it for modeless forms.

If multiple forms are displayed at a time or each one have its own size, then I would suggest to remember the position of each forms and save the position in user settings for each one. The first time, you let the user position them.

Be aware that if the user change its resolution or disconnect a secondary screen, default positionning might be better than displaying at a non visible location. You might add a test to check if the rectangle is visible and if not let Windows use default position.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900