How to set custom size for BalloonTip Control
Categories: DotNetBar for Windows Forms, How To
If you would like to set custom size for BalloonTip control follow these steps:
Handle BalloonDisplaying event
Cast sender to BalloonTip type and get hold of BalloonControl
Set the Size of the BalloonControl to desired size
Sample attached below shows how to do that. It automatically calculates size based on the text for the balloon. Default behavior is to calculate size based on the caption text of the balloon.
C#
private void BalloonTip1_BalloonDisplaying(object sender, System.EventArgs e) { DevComponents.DotNetBar.Balloon b = ((DevComponents.DotNetBar.BalloonTip)sender).BalloonControl; Graphics g = default(Graphics); int horizontalPadding = 8; int verticalPadding = 8; g = b.CreateGraphics(); try { SizeF ts = g.MeasureString(b.Text, b.Font); b.Size = new Size(ts.Width + horizontalPadding, ts.Height + b.TipLength + verticalPadding); } finally { g.Dispose(); } }
VB
Private Sub BalloonTip1_BalloonDisplaying(ByVal sender As Object, ByVal e As System.EventArgs) Handles BalloonTip1.BalloonDisplaying Dim b As DevComponents.DotNetBar.Balloon = CType(sender, DevComponents.DotNetBar.BalloonTip).BalloonControl Dim g As Graphics Dim horizontalPadding As Int32 = 8 Dim verticalPadding As Int32 = 8 g = b.CreateGraphics() Try Dim ts As SizeF = g.MeasureString(b.Text, b.Font) b.Size = New Size(ts.Width + horizontalPadding, ts.Height + b.TipLength + verticalPadding) Finally g.Dispose() End Try End Sub
Related posts:
Leave a Reply!