Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suggest you keep some "current state" variables updated so you always have a pointer to the selected Tab Page, and its child control (in the case of a tabbed-notepad emulation discussed here : a TextBox). My preference would be to keep track of the TabPage&lt;>TextBox connections using a Dictionary to avoid having to cast the TextBoxes if they are accessed using the TabPage.Controls route : the following code assumes you have a TabControl named 'tabControl1 on a Form :</p> <pre><code>Dictionary&lt;TabPage, TextBox&gt; dct_TabPageToTextBox; int tabCnt = 1; TabPage currentTabPage; TextBox currentTextBox; </code></pre> <p>So, as you create each new TabPage at run-time you call something like this :</p> <pre><code> private void AddNewTabPage() { if (dct_TabPageToTextBox == null) dct_TabPageToTextBox = new Dictionary&lt;TabPage, TextBox&gt;(); currentTabPage = new TabPage("Page " + tabCnt.ToString()); tabControl1.TabPages.Add(currentTabPage); currentTextBox = new TextBox(); dct_TabPageToTextBox.Add(currentTabPage, currentTextBox); currentTabPage.Controls.Add(currentTextBox); currentTextBox.Dock = DockStyle.Fill; currentTextBox.Text = "sample text for page " + tabCnt.ToString(); tabControl1.SelectedTab = currentTabPage; tabCnt++; } </code></pre> <p>As the end-user changes the selected TabPage you can simply update your current state variables like this :</p> <pre><code>private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { currentTabPage = tabControl1.SelectedTab; currentTextBox = dct_TabPageToTextBox[currentTabPage]; MessageBox.Show("text in current Tab Page is : " + currentTextBox.Text); } </code></pre> <p>So now have the code that is invoked by your menu choices applied only to the currentTextBox.</p> <p>best, Bill</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload