I created an Extension method that will set the page break of a RadTabStrip for visible tabs only and then split the rows in half. I have a situation where some of the tabs will be visible during certain page views.
so in your code for the page_load, you would just call:
If you have any refactorings or improvements for this snippet, I'd be interested to see it.
Enjoy!
C#:
VB:
so in your code for the page_load, you would just call:
| RadTabStrip1.FormatMultiLineTabs(False); |
If you have any refactorings or improvements for this snippet, I'd be interested to see it.
Enjoy!
C#:
| using Telerik.Web.UI; |
| using System.Runtime.ComplierServices; |
| public class RadTabStripExtensions |
| { |
| [Extension()] |
| public void FormatMultiLineTabs(ref RadTabStrip tab, bool ForceMultiLine) |
| { |
| int intTabCount = 0; |
| foreach (RadTab objTab in tab.Tabs) { |
| if (objTab.Visible) |
| { |
| intTabCount += 1; |
| } |
| } |
| if (ForceMultiLine || intTabCount >= 8) // this can be changed to the line break number |
| { |
| int intTabBreakIndex = intTabCount / 2 - 1; |
| if (intTabCount % 2 == 1) |
| { |
| intTabBreakIndex += 1; |
| } |
| tab.AddTabBreakToVisibleTabIndex(intTabBreakIndex); |
| } |
| } |
| [Extension()] |
| public void AddTabBreakToVisibleTabIndex(ref RadTabStrip tab, int VisibleIndexBreak) |
| { |
| int intIndex = 0; |
| foreach (RadTab objTab in tab.Tabs) { |
| if (objTab.Visible) |
| { |
| if (intIndex == VisibleIndexBreak) |
| { |
| objTab.IsBreak = true; |
| } |
| intIndex += 1; |
| } |
| } |
| } |
| } |
VB:
| Imports Telerik.Web.UI |
| Imports System.Runtime.CompilerServices |
| Public Module RadTabStripExtensions |
| <Extension()> _ |
| Public Sub FormatMultiLineTabs(ByRef tab As RadTabStrip, ByVal ForceMultiLine As Boolean) |
| Dim intTabCount As Integer = 0 |
| For Each objTab As RadTab In tab.Tabs |
| If objTab.Visible Then |
| intTabCount += 1 |
| End If |
| Next |
| If ForceMultiLine OrElse intTabCount >= 8 Then 'this can be changed to the line break number |
| Dim intTabBreakIndex As Integer = intTabCount \ 2 - 1 |
| If intTabCount Mod 2 = 1 Then |
| intTabBreakIndex += 1 |
| End If |
| tab.AddTabBreakToVisibleTabIndex(intTabBreakIndex) |
| End If |
| End Sub |
| <Extension()> _ |
| Public Sub AddTabBreakToVisibleTabIndex(ByRef tab As RadTabStrip, ByVal VisibleIndexBreak As Integer) |
| Dim intIndex As Integer = 0 |
| For Each objTab As RadTab In tab.Tabs |
| If objTab.Visible Then |
| If intIndex = VisibleIndexBreak Then |
| objTab.IsBreak = True |
| End If |
| intIndex += 1 |
| End If |
| Next |
| End Sub |
| End Module |