Hi guys, I want to ask a question. Currently, there is no problem with my program once I tested it on 1366 x 768 resolution. But, once I tested it on 1920 x 1080 resolution, position one of the textboxes and the height of the datagridview.
Here is the image of the program once I tested it on 1366 x 768 resolution:
Here is the image when I tested it on 1920 x 1080 resolution:
As you can see, the description textbox have a problem once I tested it on 1920 x 1080 and also the height of the datagridview.
Here is the code that I am using and the Anchor of each textboxes:
public partial class Database : Form
{
void Database_Load(object sender, EventArgs e)
{
SetComponents();
}
void SetComponents()
{
_screen = Screen.PrimaryScreen.WorkingArea;
this.pictureBox1.Location = new Point((_screen.Width / 2) - 150, (_screen.Height - _screen.Height) + 25);
this.pictureBox1.Size = new Size(260, 140);
this.label1.Text = "Product Code";
this.label1.Location = new Point(40, (_screen.Height - _screen.Height) + 125);
this.textBox1.Location = new Point(25, (_screen.Height - _screen.Height) + 150); // Text box for the Product Code
this.textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
this.label2.Text = "Quantity";
this.label2.Location = new Point(215, (_screen.Height - _screen.Height) + 125);
this.numericUpDown1.Location = new Point(185, (_screen.Height - _screen.Height) + 150); // Numeric Up Down for the Quantity
this.numericUpDown1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
this.label3.Text = "Description";
this.textBox2.Size = new Size((_screen.Width / 2) + 100, 20);
this.label3.Location = new Point((_screen.Width / 2) + 50, (_screen.Height - _screen.Height) + 125);
this.textBox2.Location = new Point((_screen.Width / 2) - 325, (_screen.Height - _screen.Height) + 150); // Text box for the Description
this.textBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left;
this.label4.Text = "Price (@ Rp)";
this.label4.Location = new Point((_screen.Width - 150), (_screen.Height - _screen.Height) + 125);
this.textBox3.Location = new Point((_screen.Width - 165), (_screen.Height - _screen.Height) + 150); // Text box for the Price
this.textBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left;
this.label5.Text = "Date / Time: ";
this.textBox4.Size = new Size(145, 20);
this.label5.Location = new Point((_screen.Width - 275), (_screen.Height - _screen.Height) + 58);
this.textBox4.Location = new Point((_screen.Width - 200), (_screen.Height - _screen.Height) + 55); // Text box for the Date / Time
this.textBox4.Anchor = AnchorStyles.Top | AnchorStyles.Left;
this.label6.Text = _welcomeText + UserInformation.CurrentLoggedInUser + " - " + UserInformation.CurrentLoggedInUserType;
this.label6.Location = new Point((_screen.Width - _screen.Width) + 10, (_screen.Height - _screen.Height) + 30);
this.button1.Text = "Submit";
this.button1.Location = new Point((_screen.Width / 2) - 150, (_screen.Height - _screen.Height) + 185);
this.button2.Text = "Reset";
this.button2.Location = new Point((_screen.Width / 2) + 100, (_screen.Height - _screen.Height) + 185);
this.button3.Text = "Delete";
this.button3.Location = new Point((_screen.Width / 2) + 20, (_screen.Height - _screen.Height) + 185);
this.button4.Text = "Edit";
this.button4.Location = new Point((_screen.Width / 2) - 70, (_screen.Height - _screen.Height) + 185);
this.button5.Text = "Update";
this.button5.Location = new Point((_screen.Width / 2) - 70, (_screen.Height - _screen.Height) + 185);
this.button6.Text = "Cancel";
this.button6.Location = new Point((_screen.Width / 2) + 100, (_screen.Height - _screen.Height) + 185);
this.button7.Text = "Information";
this.button7.Location = new Point(10, (_screen.Height - _screen.Height) + 185);
this.button8.Text = "Clear Selection";
this.button8.Size = new Size(100, 23);
this.button8.Location = new Point(10, (_screen.Height - _screen.Height) + 185);
this.dataGridView1.Size = new Size((_screen.Width) - 40, (_screen.Height - _screen.Height) + 460);
this.dataGridView1.Location = new Point((_screen.Width - _screen.Width) + 10, (_screen.Height - _screen.Height) + 225);
}
}I want that the description textbox position (location) is center between the quantity numericupdown and the price textbox. and also the height of datagridview full to the bottom of the form (like 1366 x 768 image).
I really appreciate your answer.
Thank you very much.
Freelancer Programmer