Note that there are some explanatory texts on larger screens.

plurals
  1. POtabcontrol not refreshing
    primarykey
    data
    text
    <p>I have a TabControl that starts with three TabPages in it. On the first tab there is a NumericUpDown (spinner) which displays the number of tabs and allows a user to add up to 10 extra tabs. Once they add more than about 5 or 6 it goes beyond the width of the form and the rest of the tabs are accessible by a couple of left/right arrows at the top. When going all the way to the right and then using the spinner to go back down to 0 (removing all the extra tabs and leave the starting three) it removes all tabs from the top of the pane and only by setting the spinner back to 1 does it refresh and display all 4 (3 from the start plus the 1 from the spinner). I have tried several commbinations of <code>Application.DoEvents()</code> <code>this.Refresh()</code> <code>this.Invalidate()</code> <code>this.Update()</code> but nothing seems to work. can anybody suggest a reason why it is not updating/refreshing?</p> <pre><code>public partial class Form1 : Form { TabPage[] tabs; public Form1() { InitializeComponent(); tabs = new TabPage[tabControl1.Controls.Count]; tabs[0] = tabPage1; } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int numTabs = tabControl1.Controls.Count; decimal spinnerValue = numericUpDown1.Value; if (numTabs &lt; spinnerValue) //add a tab { TabPage[] newTabs = new TabPage[(int)spinnerValue]; for (int i = 0; i &lt; numTabs; i++) { newTabs[i] = tabs[i]; } TabPage tab = new TabPage("Tab " + numTabs); newTabs[(int)spinnerValue-1] = tab; tabControl1.Controls.Add(tab); tabs = newTabs; } else //remove a tab { TabPage[] newTabs = new TabPage[(int)spinnerValue]; for (int i = 0; i &lt; spinnerValue; i++) { newTabs[i] = tabs[i]; } tabControl1.Controls.Remove(tabs[(int)spinnerValue]); tabs = newTabs; } } } </code></pre>
    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.
 

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