Posted By: Scott Bryen | May 18th, 2006 @ 11:28 AM
page 1 of 1
Comments: 4 | Views: 2363
Hey, well im wokring on a new project in C#. I have a tool bar with a  toolStripDropDownButton. When this menu is brought down i want it to add items for the amount of tabs i have on my tab control... like it does with that active tabs button on VS2005. So far i have this to add them items:

public void GetOpenTabs(ToolStripDropDownButton btnDropDown)

{

// Create a toolStripMenuItem.
ToolStripMenuItem openTab = new ToolStripMenuItem();

for (int i = 0; i < _tabControl.TabCount; i++)

{

openTab.Text = _tabControl.SelectedTab.Text;

//Add the toolStripMenuItem to the splitButton.

btnDropDown.DropDownItems.Add(openTab);

}

}

and i have this for when the menu drops down.

private void btnSelectTab_DropDownOpening(object sender, EventArgs e)

{

TabManager tm = new TabManager(tabControl, progressBar, lblStatus);

tm.GetOpenTabs(btnSelectTab);

}

However, when i open it and open it again it just keeps adding the items again and making one big list down the page. Maybe its bad logic on my part, no wait it is my bad logic/coding lol, but i was wondering if some1 could point me in the right direction as to make it so it just gets them the once.

I have maybe been thinking it needs the use of an Arraylist or something along them lines.

Thanks alot.

Scott B

mawcc
mawcc
Make it so
Maybe a

btnDropDown.DropDownItems.Clear();

before the loop where you add the items?
JohnAskew
JohnAskew
9 girl in pink sweater
[A]

private void btnSelectTab_DropDownOpening(object sender, EventArgs e)

{

TabManager tm = new TabManager(tabControl, progressBar, lblStatus);

btnTabSelect.DropDownItems.Clear();

tm.GetOpenTabs(btnSelectTab);

}


page 1 of 1
Comments: 4 | Views: 2363
Microsoft Communities