Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

VS 2008 [RESOLVED] Font Size Issue With Custom Created Listbox Control

$
0
0
I am try to Inherits a Listbox control to change StringFormatFlags direction. All is OK, but when I change the font size of Listbox control it dose not draw item properly. How to fix this issue. I am stuck with this problem from many days.

Name:  Lstbox.png
Views: 92
Size:  3.0 KB
PHP Code:

Public Class UrduListBox
    Inherits ListBox
    
Public Sub New()
        
Me.DrawMode DrawMode.OwnerDrawVariable
        AddHandler Me
.DrawItemAddressOf Draw_DrawItem
    End Sub
    
Public Sub Draw_DrawItem(ByVal sender As ObjectByVal e As DrawItemEventArgs)
        Try
            
Dim sf As New StringFormat()
            If 
sender.RightToLeft Windows.Forms.RightToLeft.Yes Then
                sf
.FormatFlags StringFormatFlags.DirectionRightToLeft
            End 
If
            
Dim br As New SolidBrush(sender.ForeColor)
            If (
e.State And DrawItemState.Selected) = DrawItemState.Selected Then
                e
.DrawBackground()
                
br Brushes.White
            
Else
                
e.Graphics.FillRectangle(New SolidBrush(e.BackColor), e.Bounds)
                
br Brushes.Black
            End 
If
            
Using fnt As New Font(sender.Font.Name.ToString(), sender.Font.Size.ToString(), FontStyle.RegularGraphicsUnit.Point)
                
e.Graphics.DrawString(sender.Items(e.Index).ToString(), fntbre.Boundssf)
            
End Using
        
Catch ex As Exception

        End 
Try
    
End Sub 

Attached Images
 

Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>