2013-04-03 129 views
0

我目前正在構建一個Web瀏覽器。更改monodevelop c中的標籤文本#

我正在使用筆記本小部件作爲tabcontrol。

但有一個問題:如何更改標籤的文本?

我有一個自定義小部件,位於每個由用戶打開的選項卡中。自定義小部件不過是一個webview。它只是讓事情變得更容易,我也可以使用這種方法來控制錯誤。

現在,由於筆記本中的選項卡是自定義小部件的父項,因此如何從自定義小部件更改選項卡的文本。我在Parent屬性中看不到Text屬性。

感謝您的幫助。

P.S.我使用的MonoDevelop 2.6,語言:C#

編輯:

我主要的主窗口中,我加入這個控制我的自定義小工具添加到我的筆記本電腦(我已經改名爲TabControl的):

// function to add a new tab 
private void AddTab(string URL) 
{ 
    // Create new label for the tab 
    Label label = new Label(); 
    label.Text = "Loading..."; 
    // Add the page to the TabControl 
    TabControl.AppendPage(control, label); 
    // Show the TabControl and its children 
    TabControl.ShowAll(); 

    // Navigate to the specified URL 
    view.Open(URL); 
} 

而且在我的自定義小部件,它僅包含Webkit.WebView,我有這樣的:

使用系統;使用WebKit;使用Gtk;

public partial class WebControl : Gtk.Bin 
{ 
    public WebView view = new WebView(); 

    public WebControl() 
    { 
     this.Build(); 

     view.Open("http://www.google.com.au"); 

     this.Add(view); 

     view.Show(); 
     view.ShowAll(); 

     this.Show(); 
     this.ShowAll(); 

     view.LoadFinished += new LoadFinishedHandler(viewLoadFinished); 
    } 

    protected void viewLoadFinished (object sender, WebKit.LoadFinishedArgs e) 
    { 
     // This is where I want to change the text of the tab, and the tab is the parent of this custom control 
    } 

    public WebView CurrentView 
    { 
     get { return view; } 
    } 

所以,有我的代碼。我只是找不到筆記本標籤的屬性來更改

+0

請顯示一些代碼 –

回答

0

的文本Gtk.Widget的.Parent屬性顯然不具有特定於父級控件的類型的屬性,因爲它不會被強制轉換到實際的窗口小部件類型。你必須投你自己。

一旦你走了父母的列表中Gtk.Notebook,你可以調用notebook.SetTabLabelText (this, "new text");(或類似的東西,我可能不會有姓名權,因爲我沒有在我面前的任何代碼)