Re: !! IMPORTANT !! Problem with owner draw listbox

Discussion in 'ASP .Net' started by Yair Cohen, Sep 4, 2003.

  1. Yair Cohen

    Yair Cohen Guest

    "Yair Cohen" <> wrote in message news:...
    > Hello all,
    >
    > i have made a class, derived from the listbox, set its property to

    ownerdraw
    > and implemnt the OnDrawItem event.
    >
    > its all work, but, i have some customers that this is not working on their
    > computers !
    > it show up for a second, and disapear !
    > - i mean, on some computers, the listitems texts and icons are show for a
    > while and disapear. after this, he can click on the items but he see

    nothing
    > ! its occur on XP OS with IE6.
    >
    > what can I do ??
    >
    > thanks a lot
    > yair
    >
    >
    > Here is the implementation code:
    >
    >
    > Protected Overrides Sub OnDrawItem(ByVal e As
    > System.Windows.Forms.DrawItemEventArgs)
    >
    > MyBase.OnDrawItem(e)
    >
    > If e.Index < 0 Then Return
    >
    > Dim centerFormat As New

    StringFormat(StringFormatFlags.DirectionRightToLeft
    > Or StringFormatFlags.NoClip)
    >
    > centerFormat.Alignment = StringAlignment.Near
    >
    > centerFormat.LineAlignment = StringAlignment.Near
    >
    > With e.Graphics
    >
    > Dim textRectF As RectangleF = New RectangleF(New PointF(e.Bounds.X,
    > e.Bounds.Y), New SizeF(e.Bounds.Width - 34, e.Bounds.Height))
    >
    > Dim imageRect As Rectangle = New Rectangle(e.Bounds.Right - 24, e.Bounds.Y

    +
    > 4, 16, 16)
    >
    > Dim butRect As Rectangle = New Rectangle(imageRect.X - 4, imageRect.Y - 4,
    > 24, 24)
    >
    > Select Case e.State
    >
    > Case DrawItemState.Selected
    >
    > '.DrawRectangle(Pens.Black, New Rectangle(e.Bounds.Left +

    (e.Bounds.Width -
    > 16) / 2, e.Bounds.Y + 4, 16, 16))
    >
    > If Not imlItems Is Nothing AndAlso CType(Me.Items(e.Index),

    HeaderData).Icon
    > < imlItems.Images.Count Then
    >
    > .DrawImage(imlItems.Images(CType(Me.Items(e.Index), HeaderData).Icon),
    > imageRect)
    >
    > End If
    >
    > .FillRectangle(SystemBrushes.Highlight, textRectF)
    >
    > .DrawString(Me.Items(e.Index).ToString, e.Font,

    SystemBrushes.HighlightText,
    > textRectF, centerFormat)
    >
    > .DrawRectangle(Pens.Navy, butRect)
    >
    > .DrawLine(Pens.White, butRect.Right, butRect.Y + 1, butRect.Right,
    > butRect.Bottom)
    >
    > .DrawLine(Pens.White, butRect.X, butRect.Bottom, butRect.Right,
    > butRect.Bottom)
    >
    > Case DrawItemState.Default, DrawItemState.None
    >
    > '.DrawRectangle(Pens.Black, New Rectangle(e.Bounds.Left +

    (e.Bounds.Width -
    > 16) / 2, e.Bounds.Y + 4, 16, 16))
    >
    > If Not imlItems Is Nothing AndAlso CType(Me.Items(e.Index),

    HeaderData).Icon
    > < imlItems.Images.Count Then
    >
    > .DrawImage(imlItems.Images(CType(Me.Items(e.Index), HeaderData).Icon),
    > imageRect)
    >
    > End If
    >
    > .FillRectangle(New SolidBrush(e.BackColor), textRectF)
    >
    > .DrawString(Me.Items(e.Index).ToString, e.Font, New

    SolidBrush(e.ForeColor),
    > textRectF, centerFormat)
    >
    > .DrawRectangle(New Pen(e.BackColor), butRect)
    >
    > .DrawLine(New Pen(e.BackColor), butRect.Right, butRect.Y + 1,

    butRect.Right,
    > butRect.Bottom)
    >
    > .DrawLine(New Pen(e.BackColor), butRect.X, butRect.Bottom, butRect.Right,
    > butRect.Bottom)
    >
    > Case DrawItemState.HotLight
    >
    > .DrawRectangle(Pens.White, butRect)
    >
    > .DrawLine(Pens.Navy, butRect.Right, butRect.Y + 1, butRect.Right,
    > butRect.Bottom)
    >
    > .DrawLine(Pens.Navy, butRect.X, butRect.Bottom, butRect.Right,
    > butRect.Bottom)
    >
    > End Select
    >
    > End With
    >
    > End Sub
    >
    >
    >
    >
    >
     
    Yair Cohen, Sep 4, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank McCown

    change dir owner

    Frank McCown, Nov 30, 2003, in forum: Perl
    Replies:
    7
    Views:
    2,058
  2. Dexter

    how to do postback in owner page?

    Dexter, Oct 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    392
    Karl Seguin
    Oct 4, 2004
  3. Saber
    Replies:
    1
    Views:
    344
    Juan T. Llibre
    Aug 20, 2005
  4. Riaz Uddin Ahmed
    Replies:
    3
    Views:
    23,803
    Roedy Green
    Aug 14, 2003
  5. Madhur Ahuja
    Replies:
    4
    Views:
    22,974
    juliadavi22
    Aug 11, 2007
Loading...

Share This Page