Quantcast
Channel: Tech Support Guy
Viewing all articles
Browse latest Browse all 29110

C# for loop associating a string with a "tab" name

$
0
0
Hi All,

Just be aware - I'm fully aware that I'm being dense... it's a while since I've programmed and I'm trying to get back into it.

I have a TabControl which I would like to be controlled by a Numeric up/down.. here's the code I've come up with:

Code:

        private void populateTabs()
        {
            string numberOfTabs;

            numberOfTabs = numberOfAdditionalTabs.Value.ToString();

            for (int i = 0; i <= Convert.ToInt32(numberOfTabs); i++)
            {
                int j;
                j = i;
                j += 2;
                string k;
                k = "tabName" + j;
                tabsAdditionalTabs.TabPages.Insert(i, k);
            }
        }

However, rather than add the tab named "tabName1" it adds a blank tab, seemingly named "tabName1".

If I try this with a literal of "tabName1" rather than var k this works... any ideas??

Viewing all articles
Browse latest Browse all 29110

Trending Articles