Problem with tabs - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with tabs

leeq3leeq3 Posts: 1Member
Hi.
My goal is to create a text editor with tabs, so I can open multiple files in tabs. My problem is that i cannot access controls in tab pages. I can only access first page. I designed first page in visual editor. Other pages may be created by clicking specified button.

Code of this button (click event):

[code]
private void tripNewpage_Click(object sender, EventArgs e)
{
TabPage newtab = new TabPage("new");
MyTabs.Controls.Add(newtab);
RichTextBox rchText = new RichTextBox();
rchText.Name = "rchText";
rchText.ContextMenuStrip = contextMenuStrip1;
rchText.Dock = DockStyle.Fill;
MyTabs.SelectedTab = newtab;
newtab.Controls.Add(rchText);
}
[/code]

This creates a new tab with a richtextbox control. I'm able to write inside the control, but i cannot use functions i used in first page.

Code of button that edites rchText control which is automatically created in first tab after running program:

[code]
private void tripBold_Click(object sender, EventArgs e)
{
if (rchText.SelectionFont == null)
{
return;
}

FontStyle style = rchText.SelectionFont.Style;

if (rchText.SelectionFont.Bold)
{
style &= ~FontStyle.Bold;
}
else
{
style |= FontStyle.Bold;
}
rchText.SelectionFont = new Font(rchText.SelectionFont, style);
rchText.Select();
}
[/code]

I want this button (bold function) to work with new richtextboxes created by tripNewpage_Click function.

How to do that?

Sorry for my english.
Sign In or Register to comment.