我目前正在构建一个web浏览器。
我正在使用一个notebook小部件作为选项卡控件。
但有一个问题:如何更改选项卡的文本?
我有一个自定义的小部件,在每个选项卡内,这是由用户打开。自定义窗口小部件只是其中的一个webview。它只是让事情变得更简单,而且我也能够使用这种方法来控制错误。
现在,由于notebook中的选项卡是自定义小部件的父部件,因此如何从自定义小部件更改选项卡的文本。我在Parent属性中看不到Text属性。
谢谢你的帮助。
附言:我使用的是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; }
}
这就是我的代码。我只是找不到notebook选项卡的属性来更改
发布于 2013-04-04 19:08:05
widget的.Parent属性显然不具有特定于父部件所属的部件类型的属性,因为它不会强制转换为实际的部件类型。你得给自己选角。
一旦你浏览了Gtk.Notebook的父母列表,你可以调用notebook.SetTabLabelText (this, "new text");
(或者类似的东西,我可能没有正确的名字,因为我前面没有任何代码)
https://stackoverflow.com/questions/15783595
复制相似问题