VB ListBox.DrawItem事件消除了下划线字符的下划线 [英] VB ListBox.DrawItem Event eliminates underline of underscore char
问题描述
我用不同的行创建了一个不同颜色的列表框,但是b
I created a listbox with different colors in different lines by
私人
Sub DrawItemHandlerL(发件人作为
对象,e 作为
DrawItemEventArgs )
Private Sub DrawItemHandlerL(sender As Object, e As DrawItemEventArgs)
  e.DrawBackground()
e.DrawBackground()
  如果 e.Index> -1
然后
If e.Index > -1 Then
    e.Graphics.FillRectangle( New
SolidBrush (cColB(aColB(e.Index) ))),e .Bounds)
e.Graphics.FillRectangle(New SolidBrush(cColB(aColB(e.Index))), e.Bounds)
    e.Graphics.DrawString(lstShow.Items(e.Index).ToString(),e.Font,
e.Graphics.DrawString(lstShow.Items(e.Index).ToString(), e.Font,
新 SolidBrush (cColF(aColS(e.Index))),e .Bounds)
New SolidBrush(cColF(aColS(e.Index))), e.Bounds)
  结束
如果
结束
Sub
End Sub
推荐答案
如果我理解的话,我无法复制这个问题。
I cant duplicate the problem if I understand it.
你能用这个简单的例子重现这个问题吗?
Can you reproduce the problem with this simple example?
如果是,那么使用编辑器上的"插入代码块"按钮将代码发布到代码块中工具栏。
If so post the code in a code block using the Insert Code Block button on the editor toolbar.
可能是
的价值 lstShow.Items(e.Index).ToString
lstShow.Items(e.Index).ToString
不是你所期望的?
Public Class Form5
Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Item_1")
ListBox1.Items.Add("Item_2")
ListBox1.Items.Add("Item_3")
ListBox1.Items.Add("Item_4")
ListBox1.DrawMode = DrawMode.OwnerDrawFixed
End Sub
Private Sub ListBox1_DrawItem(sender As Object, e As DrawItemEventArgs) Handles ListBox1.DrawItem
If e.Index > -1 Then
e.Graphics.FillRectangle(New SolidBrush(Color.Red), e.Bounds)
e.Graphics.DrawString(ListBox1.Items(e.Index).ToString(), e.Font, New SolidBrush(Color.AntiqueWhite), e.Bounds)
End If
End Sub
End Class
这篇关于VB ListBox.DrawItem事件消除了下划线字符的下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!