تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
معلومة ::: ComboBox Width
#1
كاتب الموضوع : 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

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


}}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم