This question is locked. New answers and comments are not allowed.

IT Development
Top achievements
Rank 1
IT Development
asked on 28 Sep 2009, 02:27 PM
Hello,
Having some trouble with the tabcontrol.
I want to remember tab visibility and order. When the user closes the form I save the visible tabitems in a List<string> .
When the form gets loaded I would like to restore the tabs.
I can control the visibility of the tabs but I can’t find a way to restore the order.
Anybody got a suggestion?
Kind regards,
Tim van Rooijen
3 Answers, 1 is accepted
0
Accepted

Robert
Top achievements
Rank 1
answered on 30 Sep 2009, 03:25 PM
Hey Tim,
The tab order of a RadTabStrip is determined by the order of the TabItems in the RadTabStrip.Items collection. In the following code, I save the tab order to a list then restore the tab order in radTabStrip1 based on that list.
public partial class Form1 : Form |
{ |
List<string> tabOrder = new List<string>(); |
public Form1() |
{ |
InitializeComponent(); |
} |
private void btnChangeTabOrder_Click(object sender, EventArgs e) |
{ |
List<RadItem> tabItems = new List<RadItem>((IEnumerable<RadItem>)radTabStrip1.Items); |
radTabStrip1.Items.Clear(); |
// Restore the tabs in order in the RadTabStrip |
foreach (string tabName in tabOrder) |
{ |
foreach (TabItem item in tabItems) |
{ |
if (item.Name == tabName) |
radTabStrip1.Items.Add(item); |
} |
} |
} |
private void btnSaveTabOrder_Click(object sender, EventArgs e) |
{ |
// Save order of tabs |
tabOrder.Clear(); |
foreach (TabItem item in radTabStrip1.Items) |
tabOrder.Add(item.Name); |
} |
} |
I hope this helps.
- Robert
0
Hi Robert,
Thank you for sharing your approach with us. I thing there is one more convenient solution -- using Queue<>. In that way you can very easily save and reproduce the TabItems and their order:
Greetings,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thank you for sharing your approach with us. I thing there is one more convenient solution -- using Queue<>. In that way you can very easily save and reproduce the TabItems and their order:
Queue<TabItem> itemsQueue = new Queue<TabItem>(); |
private void saveButton_Click(object sender, EventArgs e) |
{ |
this.itemsQueue.Clear(); |
for (int i = 0; i < this.radTabStrip1.Items.Count; i++) |
{ |
this.itemsQueue.Enqueue((TabItem)this.radTabStrip1.Items[i]); |
} |
this.radTabStrip1.Items.Clear(); |
} |
private void restoreButton_Click(object sender, EventArgs e) |
{ |
while (this.itemsQueue.Count > 0) |
{ |
this.radTabStrip1.Items.Add(this.itemsQueue.Dequeue()); |
} |
} |
Greetings,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

IT Development
Top achievements
Rank 1
answered on 01 Oct 2009, 12:44 PM
Hello,
Thanks for the reply's.
It worked!. I choice for the first approach because i wanted to save the order in a string.
Greetings
Tim
Thanks for the reply's.
It worked!. I choice for the first approach because i wanted to save the order in a string.
Greetings
Tim