protected void AddTabPage() { _tabCount++; // Create new query widget to append to notebook, add currently // selected database and get current pages number var queryWidget = new QueryWidget(); queryWidget.Database = GetSelectedDatabase(); var index = notebookContent.NPages; var label = new NotebookCloseButtonLabel(String.Format("New Query {0}", _tabCount)); // Add new widget to notebook and select it notebookContent.AppendPage(queryWidget, label); queryWidget.Show(); notebookContent.CurrentPage=index; // Add close event to close button of the label label.OnClosePage=OnClosePage; }
protected void OnClosePage(NotebookCloseButtonLabel label) { // Get notebook widget var notebook=label.Parent as Notebook; if(notebook==null) return; // Get page to close for(int i=0; i<notebook.NPages; i++) { var page = notebook.GetNthPage(i); var curLabel = notebook.GetTabLabel(page); // Remove page if(curLabel==label) { notebookContent.RemovePage(i); break; } } }