منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
معلومة ::: ComboBox Width - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم مقالات VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=184)
+--- الموضوع : معلومة ::: ComboBox Width (/showthread.php?tid=5329)



معلومة ::: ComboBox Width - RaggiTech - 06-10-12

كاتب الموضوع : BADRMEDIA


أحد الأعضاء المكرمين طلب أنه عند الضغط على DropDown لأداة ComboBox

يكون عرض العناصر المعروضة على أكبر عنصر موجود

ولحل ذلك


نضع هذه الاجراءية




كود :
Sub ComboBox_WidthComboBox(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim sendCombobox As ComboBox = sender
Dim wid As Integer = sendCombobox.DropDownWidth
Dim Graf As Graphics = sendCombobox.CreateGraphics
Dim Fonta As Font = sendCombobox.Font
Dim VerticalComboBox As Integer = IIf((sendCombobox.Items.Count > sendCombobox.MaxDropDownItems), SystemInformation.VerticalScrollBarWidth, 0)
Dim newWid As Integer

For Each str As String In DirectCast(sender, ComboBox).Items
newWid = CInt(Graf.MeasureString(str, Font).Width) + VerticalComboBox
If wid < newWid Then
wid = newWid
End If
Next
sendCombobox.DropDownWidth = Width

End Sub

نرسل handler الكومبو المطلوب لهذه الاجراءية


هكذا



كود :
Private Sub ComboBox1_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDown
AddHandler ComboBox1.DropDown, AddressOf ComboBox_WidthComboBox
End Sub

والله ولى التوفيق