Question

i have a WinForms TabControl which is set to

Multiline = True

I made my own custom RowsChanged Event

''' <summary>
''' Event that is raised if the rowCount of the control changed.
''' </summary>
Public Event RowsChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

Private Sub Me_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.SizeChanged, Me.SelectedIndexChanged, Me.ControlAdded, Me.ControlRemoved
    If rows <> Me.RowCount Then
        rows = Me.RowCount
        RaiseEvent RowsChanged(sender, e)
    End If
End Sub

Now I can register to that event. I want to know, the height of one row, so I can do some size calculation. Is there any way to determain that? So far I just counted pixel, which isn't quite nice.

Was it helpful?

Solution

As noted in the comment, you can use the TabControl.GetTabRect() method to retrieve the bounds of a tab at runtime. Beware that it may change on a Multiline tab control as the user navigates the tabs and rows swap position.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top