473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Ownerdrawn ListBox produces flawed graphics

Hi,

I'm trying to make an ownerdrawn ListBox that can display a custom graphic
and 2 lines of text per item.

I have tried to set the following properties on a standard ListBox control:

DrawMode = OwnerDrawFixed
ItemHeight = 32

In the DrawItem Event for the ListBox, I have placed the following code for
testing purposes:

Private Sub ListBox1_DrawItem(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
e.DrawBackground()
e.Graphics.FillRectangle(System.Drawing.Brushes.Po wderBlue, e.Bounds)
Console.WriteLine("OnDrawItem")
e.Graphics.DrawRectangle(System.Drawing.Pens.DarkB lue, e.Bounds)
e.DrawFocusRectangle()

End Sub

This code should draw a powder blue background, with a dark blue outline for
each item in the ListBox (I know the outline will lack the right and bottom
borders due to some unfortunate usage of the e.Bounds rectangle, this is for
demonstration purposes only :o)

At first all Items draw correctly, but after selecting another item, or
resizing the control or scrolling, the backgrounds (powder blue) all still
draw, and text (omitted in example code) would also draw correctly, but the
dark blue outline rectangles get clipped randomly it seems...

Am I doing something wrong? I doubt it, since I have seen examples by
Microsoft demonstrating how to create an ownerdrawn ListBox with this
problem occurring as well.

Does anyone know how to work around this issue, or have any idea what is
causing this?

TIA,

Danny van Kasteel
Nov 20 '05 #1
1 1626
Ah! Apparently, updating one's graphics drivers does the trick :o)
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martin Streller | last post by:
Hello, The code below represents a simple ownerdrawn, Listview class in C#. Its purpose is to avoid the flicker of the MS ListView. So I can't fall back to their one. Does anybody know why I...
4
by: Beeeeeeeeeeeeves | last post by:
I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with...
0
by: Andrew Baker | last post by:
Have a look at the code below. It's a really simple example where I have added two controls to a form, a textbox and a combo box. Both add owner drawn context menus to the controls, but the...
1
by: Danny van Kasteel | last post by:
Hi, I'm having some trouble drawing items in controls that I've marked as ownerdrawn. I'm currently developing an application that has ownerdrawn statusbar panels, and a listbox that contains...
3
by: André Nogueira | last post by:
Hi there! I have successfully create my own ownerdrawn menus. However, I decided to add some code for the menus to detect if their parent is a MainMenu object and, if it is, as it is the menuitem...
6
by: Geoff | last post by:
Hey all! By chance does anyone have a really good example of an ownerdrawn Listbox. I am trying to make a UI that is similar to the outlook look and feel demo done in Winforms 2.0 in 1.1. ...
2
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I...
4
by: the_mikado | last post by:
Hi, If this has been answered before I am sorry, but I want to wordwrap the items in a listbox so I dont have to use the horizontal scroll bar. Is this possible? if so how can it be done? ...
1
by: Jan | last post by:
Short: Is it possible to make an owner-drawn ListBox do a complete re-draw where items are re-measured? In my application a simple change to one of the items in the listbox could result in a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.