实际上C#应该也能看懂的,大概差别不大,遇到问题可以来论坛提问,大家和我都会帮助你的啊!
周雪峰
谢谢。
我找到了VB的例子,但是有的地方看不懂,还请帮忙解释一下。原贴地址:
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/36ee6194-621c-4e1a-96b7-e14afe77d409但是这个代码好像并不完全正确。
还有个地方也有类似的代码:
http://www.codeproject.com/KB/cpp/ImageComboBox_VBNET.aspx我有这么几个问题:
Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
.
.
.
Try
item = Me.Items(e.Index)
If (item.ImageIndex <> -1) Then
Me.ImageList.Draw(e.Graphics, bounds.Left, bounds.Top, item.ImageIndex)
e.Graphics.DrawString(item.Text, e.Font, New SolidBrush(e.ForeColor), bounds.Left + imageSize.Width, bounds.Top)
Else
e.Graphics.DrawString(item.Text, e.Font, New SolidBrush(e.ForeColor), bounds.Left, bounds.Top)
End If
Catch ex As Exception
If (e.Index <> -1) Then
e.Graphics.DrawString(Items(e.Index).ToString(), e.Font, New SolidBrush(e.ForeColor), bounds.Left, bounds.Top)
Else
e.Graphics.DrawString(Text, e.Font, New SolidBrush(e.ForeColor), bounds.Left, bounds.Top)
End If
End Try
MyBase.OnDrawItem(e)
End Sub
MyBase.OnDrawItem(e)怎么解释?能不能看作引用基类的OnDrawItem来执行Override中的修改?
Public Overrides Function ToString() As String
Return _text
End Function
这个是干什么用的?查了查,还是不明白为什么要这么做。
谢谢。