- 題名: コンボボックスのリスト表示部のイベント
- 日時: 2009/09/30 11:15:49
- ID: 25460
- この記事の返信元:
- (なし)
- この記事への返信:
- [25469] Re[1]: コンボボックスのリスト表示部のイベント2009/09/30 23:21:04
- ツリーを表示
お疲れ様です。
> 反転した時のイベントは発生しないのですか?
ComboBoxをOwnerDrawして、DrawItemイベントを拾う方法が考えられます。
試してみてください。
# 吹き出しの表示方法は分かりませんでした。
# もっとよい方法がないか私も調べてみます。
' ComboBox1をFormに配置してください
Public Class Form8
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
With Me.ComboBox1
.DrawMode = DrawMode.OwnerDrawFixed
.ValueMember = "Code"
.DisplayMember = "Name"
.DataSource = Me._helperCreateDataTable
End With
MyBase.OnLoad(e)
End Sub
Private Function _helperCreateDataTable() As DataTable
Dim dt As New DataTable
dt.Columns.Add("Code", GetType(String))
dt.Columns.Add("Name", GetType(String))
For i As Integer = 1 To 6
dt.Rows.Add("Code" + i.ToString, "値" + i.ToString)
Next
Return dt
End Function
Private Sub ComboBox1_DrawItem(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim cbo As ComboBox = Me.ComboBox1
Console.WriteLine("DrawItem")
e.DrawBackground()
Dim br As Brush
If e.State = DrawItemState.Selected Then
br = SystemBrushes.HighlightText
Else
br = SystemBrushes.WindowText
End If
Dim o As Object = DirectCast(cbo.Items(e.Index), DataRowView).Item(cbo.DisplayMember)
e.Graphics.DrawString(Convert.ToString(o), cbo.Font, br, e.Bounds)
End Sub
End Class
分類:[.NET]
コンボボックスの▼をマウスでクリックして、リストが表示された状態で、
表示されたリスト部分をマウスでポイントするとその行が反転しますが、
反転した時のイベントは発生しないのですか?
リストの項目ごとに吹き出しもたいなものを表示できたらと思っています。