Search code examples
c#monomonodevelopgtk#

IF-statement depending on notebook.page.label (gtk#)


I am realtively new to C# and am trying to have an action in my toolbar that will act depending on which page in a notebook that I am currently "viewing".

Here is what I am trying to do:

protected void OnRefreshActionActivated (object sender, EventArgs e)
{

    if (mynotebook.CurrentPage.Equals == pgMyNotebookPage) 
    {
        lblMsg.Text = "You are viewing the first page";
    } 
    else 
    {
        lblMsg.Text = "You are viewing the second page";
    }

}

However I can't seem to get this to work. Any pointers?

Regards,

Christian


Solution

  • I solved this by creating a messagedialog that showed me the output of mynotebook.CurrentPage. It turned out that each page was assigned a number starting with 0.

    This is the working code:

    protected void OnRefreshActionActivated (object sender, EventArgs e)
    {
        if (nbMain.CurrentPage == 0)
        {
                lblMsg.Text = "You are viewing the first page.";
    
        }
        else
        { 
               lblMsg.Text = "You are viewing the first page.";
    
        }
    

    }