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!


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
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):

private void tripNewpage_Click(object sender, EventArgs e)
TabPage newtab = new TabPage("new");
RichTextBox rchText = new RichTextBox();
rchText.Name = "rchText";
rchText.ContextMenuStrip = contextMenuStrip1;
rchText.Dock = DockStyle.Fill;
MyTabs.SelectedTab = newtab;

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:

private void tripBold_Click(object sender, EventArgs e)
if (rchText.SelectionFont == null)

FontStyle style = rchText.SelectionFont.Style;

if (rchText.SelectionFont.Bold)
style &= ~FontStyle.Bold;
style |= FontStyle.Bold;
rchText.SelectionFont = new Font(rchText.SelectionFont, style);

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.