更改monodevelop c#中的制表符文本
本文关键字:制表符 文本 monodevelop 更改 | 更新日期: 2023-09-27 18:07:07
我正在构建一个web浏览器。
我正在使用一个笔记本小部件作为tabcontrol.
但是有一个问题:我如何改变标签的文本?
我有一个自定义小部件,它位于用户打开的每个选项卡内。自定义小部件只不过是一个webview。它只是使事情更容易,我也能够使用这种方法控制错误。
现在,由于笔记本中的选项卡是自定义小部件的父项,我如何从自定义小部件更改选项卡的文本呢?我没有在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; }
}
这就是我的代码。我只是找不到笔记本的标签属性来改变
Gtk。Widget的. parent属性显然没有特定于父部件类型的属性,因为它没有被强制转换为实际的小部件类型。
一旦你沿着双亲列表走到Gtk。笔记本,你可以叫它notebook.SetTabLabelText (this, "new text");
(或者类似的东西,我的名字可能不对,因为我面前没有任何代码)