Public Class frmMsgBox Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click Me.DialogResult = Windows.Forms.DialogResult.Yes Me.Close() End Sub Private Sub btnno_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnno.Click Me.DialogResult = Windows.Forms.DialogResult.No Me.Close() End Sub Private Sub btnAbbruch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbbruch.Click Me.DialogResult = Windows.Forms.DialogResult.Cancel Me.Close() End Sub Private Sub frmMsgBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim DistanceBetweenTxtBxs As Integer Dim dstncBetweenTb2DsgnTime_Tb2Autosized As Integer Dim tb2Btm As Integer Dim g As Graphics = CreateGraphics() Dim sz As SizeF = g.MeasureString(txtmsg.Text, txtmsg.Font, txtmsg.ClientSize.Width) txtmsg.MaxLength = txtmsg.Text.Length txtmsg.Height = CType(sz.Height, Integer) ' Me.txtmsg.BackColor = Color.AliceBlue 'Me.txtmsg.Width = wi Me.Panel1.Height = Me.txtmsg.Height + 60 Me.btnAbbruch.Top = Panel1.Bottom + 10 Me.btnno.Top = Panel1.Bottom + 10 Me.btnOK.Top = Panel1.Bottom + 10 Me.btnYes.Top = Panel1.Bottom + 10 Me.Height = Me.Panel1.Height + Me.btnOK.Height + 50 'txtmsg.Width = CType(sz.Width, Integer) g = Nothing sz = Nothing Exit Sub 'Me.txtmsg.AutoSize = False 'Dim mysizee As New System.Drawing.Size 'Dim myfont As New System.Drawing.Font(Me.txtmsg.Font.FontFamily, Me.txtmsg.Font.Size) 'Dim g As Graphics = CreateGraphics() 'Dim sz As SizeF = g.MeasureString(Tb1.Text, Tb1.Font, Tb1.ClientSize.Width) 'Dim wi As Integer = txtmsg.Width 'Me.txtmsg.Size = PreferredSize 'Me.txtmsg.BackColor = Color.AliceBlue 'Me.txtmsg.Width = wi 'Me.Panel1.Height = Me.txtmsg.Height 'Me.btnAbbruch.Top = Panel1.Bottom + 10 'Me.btnno.Top = Panel1.Bottom + 10 'Me.btnOK.Top = Panel1.Bottom + 10 'Me.btnYes.Top = Panel1.Bottom + 10 'Me.Height = btnOK.Bottom + 10 End Sub Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click Me.DialogResult = Windows.Forms.DialogResult.OK Me.Close() End Sub Private Function CalculateHeight() As Single Dim g As Graphics = txtmsg.CreateGraphics Return g.MeasureString(txtmsg.Text, txtmsg.Font).Width End Function End Class