22-10-19, 01:54 AM
جرب هذا الكود
غير الرقم 100 إلى ما يناسبك (عرض الأداة الإفتراضي)
المصدر : https://stackoverflow.com/a/8124085/3814729
غير الرقم 100 إلى ما يناسبك (عرض الأداة الإفتراضي)
كود :
Const width As Integer = 100
Private Sub textBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim font As Font = New Font(textBox1.Font.Name, textBox1.Font.Size)
Dim s As Size = TextRenderer.MeasureText(textBox1.Text, font)
If s.Width > width Then
textBox1.Width = s.Width
End If
End Subالمصدر : https://stackoverflow.com/a/8124085/3814729

