Howdy, Stranger!

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


Problem with tabs

leeq3leeq3 Member Posts: 1
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.