Add and remove controls from NotebookPage

View: New views
2 Messages — Rating Filter:   Alert me  

Add and remove controls from NotebookPage

by vbtricks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Salut,

depending on a state at runtime I need to replace the content of a page in a Notebook-Control. How do I accomplish this?

(I've started using GTK# yesterday and unfortunately my Windows Forms knowledge is of little use)


Thanks in advance,

Stefan

Re: Add and remove controls from NotebookPage

by countcb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

vbtricks wrote:
depending on a state at runtime I need to replace the content of a page in a Notebook-Control. How do I accomplish this?
The mono doc is very usefull. Not only for beginners.

The documentation for the gtk notepage:
http://www.go-mono.com/docs/index.aspx?link=T%3aGtk.Notebook%2f*

This two methods are interesting:
AppendPage(Widget, Widget) : int
RemovePage(int)


Example:

// create the widget you want in the notebook. For example a ScrolledWindow
ScrolledWindow scrolledWindow = new ScrolledWindow();
//add content to the scrolledWindow...

// create the second widget you want in the notebook.
ScrolledWindow scrolledWindow2 = new ScrolledWindow();
//add content to the scrolledWindow2...

// create a notebook
Notebook notebook = new Notebook();
// add the first contents, it will return the number of this page
int page = notebook.AppendPage(scrolledWindow, new Label("Tab with scrolledWindow"));
// remove the page with the numer we got from the add method
notebook.RemovePage(page);
// add the second content, again we save the page number
int page = notebook.AppendPage(scrolledWindow2, new Label("Tab with scrolledWindow2"));

You could also have a look at
InsertPage(Widget, Widget, int) : int
if you don't want the page to be at the last position but at a specific position.


Hope that helps!