We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to find out the number of rows painted in the TabControlAdv?

 

It is possible by deriving TabControlAdv and count the number of rows when TabPageAdv is painted.

C#

public int GetNumOfRows()

{

float minHeight = 0, currentLineHeight = 0, maxHeight = 0;

int rows = 1;

SizeF preferedTabSize = SizeF.Empty;

SizeF overlappedSize = SizeF.Empty;

Graphics g = this.CreateGraphics();

SizeF prefSize = new SizeF(this.ClientRectangle.Width, this.ClientRectangle.Height);

overlappedSize = TabRendererFactory.GetRegisteredExtender

(this.m_tabPanelRenderer.TabPanelData.TabStyle).GetOverlapSize(this.m_tabPanelRenderer.TabPanelData.TabSize);

overlappedSize.Height += this.m_tabPanelRenderer.TabPanelData.AdjustTopGap;

float usedUpLineWidth = overlappedSize.Width;

float availableWidth = prefSize.Width;

int i=0;

foreach (ITabRenderer render in this.m_tabPanelRenderer.Renderers)

{

preferedTabSize = ((ITabRenderer)this.m_tabPanelRenderer.Renderers[i]).GetPreferredSize(g);

if (preferedTabSize.Width + usedUpLineWidth

<= availableWidth || usedUpLineWidth <= overlappedSize.Width)

}

// enough space available in current line

usedUpLineWidth += preferedTabSize.Width;

}

else

{

// move to next line

minHeight += currentLineHeight;

rows++;

// This item becomes the first item in the new line

usedUpLineWidth = overlappedSize.Width + preferedTabSize.Width;

if (maxHeight < currentLineHeight)

maxHeight = currentLineHeight;

currentLineHeight = 0F;

}

if (currentLineHeight < preferedTabSize.Height)

currentLineHeight = preferedTabSize.Height;

i++;

}

return rows;

}

public bool ShouldDrawVisible(ITabData tdata)

{

return (tdata.TabVisible);

}

VB

Public Function GetNumOfRows() As Integer

Dim minHeight As Single = 0, currentLineHeight As Single = 0, maxHeight As Single = 0

Dim rows As Integer = 1

Dim preferedTabSize As SizeF = SizeF.Empty

Dim overlappedSize As SizeF = SizeF.Empty

Dim g As Graphics = Me.CreateGraphics()

Dim prefSize As SizeF = New SizeF(Me.ClientRectangle.Width, Me.ClientRectangle.Height)

overlappedSize = TabRendererFactory.GetRegisteredExtender

(Me.m_tabPanelRenderer.TabPanelData.TabStyle).GetOverlapSize(Me.m_tabPanelRenderer.TabPanelData.TabSize)

overlappedSize.Height += Me.m_tabPanelRenderer.TabPanelData.AdjustTopGap

Dim usedUpLineWidth As Single = overlappedSize.Width

Dim availableWidth As Single = prefSize.Width

Dim i As Integer=0

For Each render As ITabRenderer In Me.m_tabPanelRenderer.Renderers

preferedTabSize = (CType(Me.m_tabPanelRenderer.Renderers(i), ITabRenderer)).GetPreferredSize(g)

If preferedTabSize.Width + usedUpLineWidth <= availableWidth OrElse usedUpLineWidth <= overlappedSize.Width

Then

'' enough space available in current line

usedUpLineWidth += preferedTabSize.Width

Else

'' move to next line

minHeight += currentLineHeight

rows += 1

'' This item becomes the first item in the new line

usedUpLineWidth = overlappedSize.Width + preferedTabSize.Width

If maxHeight < currentLineHeight Then

maxHeight = currentLineHeight

End If

currentLineHeight = 0F

End If

If currentLineHeight < preferedTabSize.Height Then

currentLineHeight = preferedTabSize.Height

End If

i += 1

Next render

Return rows

End Function

Public Function ShouldDrawVisible(ByVal tdata As ITabData) As Boolean

Return (tdata.TabVisible)

End Function

Sample:

http://websamples.syncfusion.com/samples/KB/Tools.Windows/KB_TabControlsAdvRowCount/main.htm

Article ID: Published Date: Last Revised Date: Platform: Control:
1790 04/30/2011 07/10/2014 WinForms TabControlAdv
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon