تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] ListBix
#2
يمكنك فعل لك ولكن يتوجب عليك ان ترسم عناصر الليست بنفسك

غير الخاصية DrawMode الى OwnerDrawFixed
وكذلك الخاصية ItemHeight الى ارتفاع العنصر الذي تراه مناسب

عرف المتغير     SelectedColor للون العنصر المختار للبرنامج كله :

كود :
   Dim SelectedColor As Color = Color.Gold


الآن في حدث DrawItem اضف الكود التالي الي يقوم برسم العناصر 

كود :
   Private Sub ListBox1_DrawItem(sender As Object, e As DrawItemEventArgs) Handles ListBox1.DrawItem

       Dim lst As ListBox = DirectCast(sender, ListBox)

       If e.Index < 0 Then Return

       If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
           e = New DrawItemEventArgs(e.Graphics,
                                     e.Font,
                                     e.Bounds,
                                     e.Index,
                                     e.State Xor DrawItemState.Selected,
                                     e.ForeColor,
                                     SelectedColor)
       End If


       e.DrawBackground()
        Dim str As String = lst.GetItemText(lst.Items(e.Index))

       Dim StrPoint As New Point
       Dim StrWidth = e.Graphics.MeasureString(str, e.Font).Width
       StrPoint.X = IIf(lst.RightToLeft = RightToLeft.Yes,
                        e.Bounds.X + e.Bounds.Width - StrWidth,
                        e.Bounds.X)

       StrPoint.Y = e.Bounds.Y + (e.Bounds.Height - e.Font.Height) * 0.5

       e.Graphics.DrawString(str,
                             e.Font,
                             New SolidBrush(lst.ForeColor),
                             StrPoint)



   End Sub
https://stackoverflow.com/a/3663856/14137871
الرد }}}


الردود في هذا الموضوع
ListBix - بواسطة yazanahmed - 27-08-20, 03:58 PM
RE: ListBix - بواسطة Anas Mahmoud - 27-08-20, 07:50 PM
RE: ListBix - بواسطة yazanahmed - 29-08-20, 01:31 AM

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


يقوم بقرائة الموضوع: