Question

I have been working on a Windows Forms application based in c# and I am in need of some assistance.

as seen in sample code:

frmPopUp frmAdd = new frmPopUp();

frmAdd.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
frmAdd.Location = new System.Drawing.Point(450, 200);
frmAdd.showdialog();
this.Create();

and when I use this function in code and click anywhere outside the frmAdd boundry it blinks or flickers which is annoying and I dont want that. (But "Create" function does called after form is closed) this is my problem I dont want blinking and at same time function should also be called after the form closes.

After some search, I tried dll import solutions from the link mentioned below - in this case the problem I am facing is that the Create function should always be called after frmadd form is closed. But it gets called when the form is created. e.g.:

SetNativeEnabled(false);
frmPopUp frmAdd = new frmPopUp();

frmAdd.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
frmAdd.Location = new System.Drawing.Point(450, 200);
frmAdd.Closed += (s, a) =>
{
    SetNativeEnabled(true);
};
frmAdd.Show(this);

this.Create();

I am fairly new to making Windows Forms applications so there are still things I don't understand so be patient with me if I don't understand something at first.

These are the links that I've tried:

Was it helpful?

Solution

the Create function should always be called after frmadd form is closed.

So change up your anonymous delegate:

private void button1_Click(object sender, EventArgs e)
{
    frmPopUp frmAdd = new frmPopUp();

    frmAdd.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    frmAdd.Location = new System.Drawing.Point(450, 200);
    frmAdd.Closed += (s, a) =>
    {
        this.Create();
    };
    frmAdd.Show(this);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top