Nun das klingt kompliziert.
Es läuft ja soweit ganz gut. Ich habe im DrawEventItem lediglich diesen TeilCode, der das ganze steuert.
...
Dim lItemSelected As Boolean = ((e.State And DrawItemState.Selected) = _
DrawItemState.Selected)
If lItemSelected Then
Dim bbr As New SolidBrush(cValue.SelectedBackcolor)
Dim bb As New Pen(cValue.SelectedBorderColor, _
cValue.SelectedBorderWidth)
e.Graphics.FillRectangle(bbr, e.Bounds)
e.Graphics.DrawRectangle(bb, e.Bounds)
If check Then
If MyBase.SelectionMode = _
Windows.Forms.SelectionMode.MultiSimple Or _
MyBase.SelectionMode = _
Windows.Forms.SelectionMode.MultiExtended Then
ControlPaint.DrawCheckBox(e.Graphics, CheckRec, _
ButtonState.Checked)
ElseIf MyBase.SelectionMode = _
Windows.Forms.SelectionMode.One Then
ControlPaint.DrawRadioButton(e.Graphics, CheckRec, _
ButtonState.Checked)
Else
chckwidth = stdwidth
End If
End If
bbr.Dispose()
Else
Dim bbr As New SolidBrush(cValue.UnSelectedBackColor)
Dim bb As New Pen(Color.Transparent, cValue.SelectedBorderWidth)
e.Graphics.FillRectangle(bbr, e.Bounds)
e.Graphics.DrawRectangle(bb, e.Bounds)
If check Then
If MyBase.SelectionMode = _
Windows.Forms.SelectionMode.MultiSimple Or _
MyBase.SelectionMode = _
Windows.Forms.SelectionMode.MultiExtended Then
ControlPaint.DrawCheckBox(e.Graphics, CheckRec, _
ButtonState.Normal)
ElseIf MyBase.SelectionMode = _
Windows.Forms.SelectionMode.One Then
ControlPaint.DrawRadioButton(e.Graphics, CheckRec, _
ButtonState.Normal)
Else
chckwidth = stdwidth
End If
End If
bbr.Dispose()
End If
If mImageList IsNot Nothing Then
If img Then
Me.ImageList.Draw(e.Graphics, imgx, e.Bounds.Y, _
ImageBoxWidth, e.Bounds.Height, e.Index)
e.Graphics.DrawRectangle(p, imgx, e.Bounds.Y, _
ImageBoxWidth, e.Bounds.Height)
End If
End If
If MyBase.Items.Count > 0 Then
stritem = CStr(Me.Items(e.Index)).Replace("_", vbCrLf)
If icount = True Then e.Graphics.DrawString((e.Index + _
1).ToString & ". ", Me.Font, New SolidBrush(e.ForeColor), _
stringreccount)
e.Graphics.DrawString(stritem, Me.Font, New SolidBrush( _
e.ForeColor), stringrec)
End If
... meine Vermutung lag erst, dass es in der Abfrage liegt, ob es selected ist.
Dann dachte ich, wenn ich im DoubleClick-Event einen Flag setze und dann bevor ich es auf Checked setze, vorher prüfe ob der Flag gesetzt wurde. Das ging aber auch nicht so wie ich wollte
Gruss Caddy |