I have an tabcontrol that hads 5 tabs, tab1, tab2, tab3, tab4, tab5.
each ultratab has its own ugrid, I am trying to write that basically puts the tab first or infront of the tabs where where grids have data or records, but if grids does not have rows or data, put the grid tab last within in the tabcontrol. the customers wants to keep the tab visible at all times.
example
tab1: grid1 has 5 records, tab2: grid2 has 0 records, tab3: grid3 has 0 records, tab4: grid4 has 3 records, tab5: grid5 has 2 records
You are basically shifting all of the tabs with grids with no rows to the end of the tabcontrol
Output:
tab1, tab4, tab5, tab2, tab3.
VulpesPosted Feb 21, 2012, 6:27 AM
David SmithPosted Feb 21, 2012, 3:43 AM
List
int index = 0;
foreach (UltraTab tabItem in ultraTabControl2.Tabs)
{
foreach (var control in tabItem.TabPage.Controls)
{
index++;
if (control.GetType() == typeof(Infragistics.Win.UltraWinGrid.UltraGrid))
{
if (((UltraGrid)control).Rows.Count == 0)
{
//INSERT GRID
ultraTabControl2.TabIndex = index;
ultraTabControl2.Controls.Add((UltraGrid)control);
}
//else
//{
// //ADD GRID
// ultraTabControl2.Controls.Add((UltraGrid)control);
//}
}
}
}
David SmithPosted Feb 19, 2012, 7:53 PM
so need to create anything new, i just want to basically manage the index of each tab.
So there exist one tabcontrol1 that has five tab, each tab has its on grid view. the tabs that contain grid views with no data move tabs to the back, else move tabs with grid view containing data to the front.
FroglegPosted Feb 19, 2012, 7:12 PM
private void button2_Click(object sender, EventArgs e)
{
string title = "TabPage1";
TabPage myTabPage = new TabPage(title);
myTabPage.BackColor = Color.White;
tabControl1.TabPages.Add(myTabPage);
foreach (Control ctl in tabControl1.TabPages[0].Controls)
{
if (ctl is TextBox)
{
TextBox tbox = new TextBox();
tbox.Location = ctl.Location;
tbox.Size = ctl.Size;
myTabPage.Controls.Add(tbox);
}
else if (ctl is Label)
{
Label lbl = new Label();
lbl.Location = ctl.Location;
lbl.Text = ctl.Text;
myTabPage.Controls.Add(lbl);
}
else if (ctl is Button)
{
Button bttn = new Button();
bttn.Location = ctl.Location;
bttn.Text = ctl.Text;
myTabPage.Controls.Add(bttn);
}
}
tabControl1.TabPages.RemoveAt(0);
}
}