15-08-14, 08:00 AM
السلام عليكم ورحمة الله وبركاته
تفضل أخي هذا الكود في حال كان النص سطرا واحدا
وعليه فقِس في الحالة الثانية...
بالتوفيق
تفضل أخي هذا الكود في حال كان النص سطرا واحدا
كود :
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.PreferredSize.Width > TextBox1.Width Then
Dim FontSize As Single = TextBox1.Font.Size
Dim NewWidth As Integer = 0
Do
With TextBox1
FontSize -= 0.001F
NewWidth = TextRenderer.MeasureText(.Text, New Font(.Font.Name, FontSize, Font.Style)).Width
If NewWidth <= .Width Then
.Font = New Font(.Font.Name, FontSize, Font.Style)
Exit Do
End If
End With
Loop
End If
End Subوعليه فقِس في الحالة الثانية...
بالتوفيق

