[英]Determain the Height of a TabRow in a TabControl (VB.NET)
i have a WinForms TabControl which is set to 我有一个WinForms TabControl设置为
Multiline = True
I made my own custom RowsChanged Event 我做了自己的自定义RowsChanged事件
''' <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.
到目前为止,我只计算了像素,这不是很好。
As noted in the comment, you can use the TabControl.GetTabRect() method to retrieve the bounds of a tab at runtime. 如注释中所述,您可以使用TabControl.GetTabRect()方法在运行时检索选项卡的边界。 Beware that it may change on a Multiline tab control as the user navigates the tabs and rows swap position.
请注意,当用户导航选项卡和行交换位置时,它可能会在“多行”选项卡控件上更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.