我用这个创建一个新标签:
private void addTabs(RichTextBox richTextBox,string name)
{
//Add Tabs
try
{
if (tabControl1.TabPages.Count <= 8)
{
TabPage tabPage = new TabPage();
tabPage.Controls.Add(richTextBox);
if (name == null)
{
tabPage.Text = "Page: " + (tabControl1.TabCount + 1).ToString();
tabPage.Tag = "Page: " + (tabControl1.TabCount + 1).ToString();
}
else
{
tabPage.Text = name;
tabPage.Tag = name;
}
richTextBox.Dock = DockStyle.Fill;
tabControl1.TabPages.Add(tabPage);
}
else
MessageBox.Show("You have reached the max threshold for tabs.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine(e.Message);
}
}
这将创建一个新选项卡并为其提供一个富文本框。我知道如何使用对话框保存文件,但如何访问richtextbox?