I am creating a program in C# Windows Form Application.
Let me give you a scenario of what I am doing:
Does anyone know how to "redo" the main menu after logging in, depending on permission value?
Maybe this?
const int firstButtonY = 20;
const int padding = 20;
int currentY = firstButtonY;
foreach (var control in this.Controls)
{
if (control.GetType() != typeof(System.Windows.Forms.Button))
continue;
var curButton = (Button) control;
if (!curButton.Visible)
continue;
curButton.Top = currentY;
currentY += padding + curButton.Height;
}
Instead of open new instance (in my case, Form3) in Form1 in Form1_Load
frm3 = new Form3(this);
and show after specified event trigger
frm3.Show();
and cancel the Form3_Closing
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
frm3 = new Form3(this);
frm3.Show();
and comment the create new instance in Form1_Load
//frm3 = new Form3(this);
and comment the Hide form3 part
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
{
//e.Cancel = true;
//this.Hide();
}
because frm3.Show()
after the form3 this.Hide()
WON'T triggered
private void Form3_Load(object sender, EventArgs e)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.