How to identify which Tabpage is being closed

Asked

Viewed 101 times

0

Good morning, how are you? I am working with Xtratabcontrol, and when I close a tab, I need to know which tab was closed. today at the event xtraTabControl1_CloseButtonClick, I’m doing it this way:

`

private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e) //click fechar aba 
        {
            ClosePageButtonEventArgs arg = e as ClosePageButtonEventArgs;
            (arg.Page as XtraTabPage).PageVisible = false;

        if (//CONDIÇÂO SOMENTE PARA A PAGE 1) // so executa se for a aba 1
        {
            foreach (Control ctl in xtraTabPage1.Controls)
            {
                if (ctl is TextEdit)
                {
                    ((TextEdit)(ctl)).Text = string.Empty;
                }

                if (ctl is TextBox)
                {
                    ((TextBox)(ctl)).Text = string.Empty;
                }
            }

            id_v = 0;
            gridControl2.DataSource = null;
            gridView2.Columns.Clear();
            gridView1.ActiveFilterString = "";
        }
    }`

Someone could help me with the IF condition?

Thanks

  • 2

    Hi Thomas! Arg.Page (2° command) does not contain information necessary for your verification?

  • Exactly, I hadn’t noticed. Thank you.

1 answer

0

galley got,

I made the condition as follows:

arg.Page == xtraTabPage1

Final code:

private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e) //click fechar aba 
    {
        ClosePageButtonEventArgs arg = e as ClosePageButtonEventArgs;
        (arg.Page as XtraTabPage).PageVisible = false;

        if (arg.Page == xtraTabPage1) // so executa se for a aba um
        {
            foreach (Control ctl in xtraTabPage1.Controls)
            {
                if (ctl is TextEdit)
                {
                    ((TextEdit)(ctl)).Text = string.Empty;
                }

                if (ctl is TextBox)
                {
                    ((TextBox)(ctl)).Text = string.Empty;
                }
            }

            id_v = 0;
            gridControl2.DataSource = null;
            gridView2.Columns.Clear();
            gridView1.ActiveFilterString = "";
        }
    }

Thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.