473,545 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET 2.0 problem with owner drawn listview

Ok whats going on here... got a couple problems... this is relevant now to
this group since .NET 2.0 is finally RTM

1) draws really slow when making it a large form (resizing speed is jerky)
to a res from 100x100 to 1280x1024 once it gets above 500x500 it starts
jerking you can see the screen refreshing as it paints

2) sometimes the background selection when you select multiple items then
move the mouse around on the screen dissapear (turn white) mainly column 0
background

3) the focus selection rectangle is black only, it should be inversed of the
selection color shouldnt it? so it would stand out, when its not owner drawn
and the selection color is dark blue the focus rectangle draws yellow, in
owner drawn it draws black and is impossible to see on a dark background

here is my example code.. (all images in image list are 16x16 PNG images
with very little transparent alpha channel pixels)


<Global.Microso ft.VisualBasic. CompilerService s.DesignerGener ated()> _

Partial Class Form1

Inherits System.Windows. Forms.Form

'Form overrides dispose to clean up the component list.

<System.Diagnos tics.DebuggerNo nUserCode()> _

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Disp ose()

End If

MyBase.Dispose( disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form
Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnos tics.DebuggerSt epThrough()> _

Private Sub InitializeCompo nent()

Me.components = New System.Componen tModel.Containe r

Dim resources As System.Componen tModel.Componen tResourceManage r = New
System.Componen tModel.Componen tResourceManage r(GetType(Form1 ))

Me.ListView1 = New System.Windows. Forms.ListView

Me.ColumnHeader 1 = New System.Windows. Forms.ColumnHea der

Me.ColumnHeader 2 = New System.Windows. Forms.ColumnHea der

Me.ColumnHeader 3 = New System.Windows. Forms.ColumnHea der

Me.ColumnHeader 4 = New System.Windows. Forms.ColumnHea der

Me.ColumnHeader 5 = New System.Windows. Forms.ColumnHea der

Me.ColumnHeader 6 = New System.Windows. Forms.ColumnHea der

Me.ImageList1 = New System.Windows. Forms.ImageList (Me.components)

Me.SuspendLayou t()

'

'ListView1

'

Me.ListView1.Co lumns.AddRange( New System.Windows. Forms.ColumnHea der()
{Me.ColumnHeade r1, Me.ColumnHeader 2, Me.ColumnHeader 3, Me.ColumnHeader 4,
Me.ColumnHeader 5, Me.ColumnHeader 6})

Me.ListView1.Do ck = System.Windows. Forms.DockStyle .Fill

Me.ListView1.Fu llRowSelect = True

Me.ListView1.Lo cation = New System.Drawing. Point(0, 0)

Me.ListView1.Na me = "ListView1"

Me.ListView1.Ow nerDraw = True

Me.ListView1.Si ze = New System.Drawing. Size(627, 412)

Me.ListView1.Sm allImageList = Me.ImageList1

Me.ListView1.Ta bIndex = 0

Me.ListView1.Us eCompatibleStat eImageBehavior = False

Me.ListView1.Vi ew = System.Windows. Forms.View.Deta ils

'

'ColumnHeader1

'

Me.ColumnHeader 1.Name = "ColumnHead er1"

'

'ColumnHeader2

'

Me.ColumnHeader 2.Name = "ColumnHead er2"

'

'ColumnHeader3

'

Me.ColumnHeader 3.Name = "ColumnHead er3"

'

'ColumnHeader4

'

Me.ColumnHeader 4.Name = "ColumnHead er4"

'

'ColumnHeader5

'

Me.ColumnHeader 5.Name = "ColumnHead er5"

'

'ColumnHeader6

'

Me.ColumnHeader 6.Name = "ColumnHead er6"

'

'ImageList1

'

Me.ImageList1.I mageStream =
CType(resources .GetObject("Ima geList1.ImageSt ream"),
System.Windows. Forms.ImageList Streamer)

Me.ImageList1.T ransparentColor = System.Drawing. Color.Transpare nt

Me.ImageList1.I mages.SetKeyNam e(0, "Script-2.png")

Me.ImageList1.I mages.SetKeyNam e(1, "About.png" )

Me.ImageList1.I mages.SetKeyNam e(2, "Clock.png" )

Me.ImageList1.I mages.SetKeyNam e(3, "Debug-Watch.png")

'

'Form1

'

Me.AutoScaleDim ensions = New System.Drawing. SizeF(6.0!, 13.0!)

Me.AutoScaleMod e = System.Windows. Forms.AutoScale Mode.Font

Me.ClientSize = New System.Drawing. Size(627, 412)

Me.Controls.Add (Me.ListView1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout (False)

End Sub

Friend WithEvents ListView1 As System.Windows. Forms.ListView

Friend WithEvents ColumnHeader1 As System.Windows. Forms.ColumnHea der

Friend WithEvents ColumnHeader2 As System.Windows. Forms.ColumnHea der

Friend WithEvents ColumnHeader3 As System.Windows. Forms.ColumnHea der

Friend WithEvents ColumnHeader4 As System.Windows. Forms.ColumnHea der

Friend WithEvents ColumnHeader5 As System.Windows. Forms.ColumnHea der

Friend WithEvents ColumnHeader6 As System.Windows. Forms.ColumnHea der

Friend WithEvents ImageList1 As System.Windows. Forms.ImageList

End Class

Public Class Form1

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

For i As Integer = 0 To 400

Dim lvitem As New ListViewItem

With lvitem

.Text = "test"

.SubItems.Add(" 1")

.SubItems.Add(" 2")

.SubItems.Add(" 3")

.SubItems.Add(" 4")

.SubItems.Add(" 5")

End With

Me.ListView1.It ems.Add(lvitem)

Next

End Sub

Private Sub ListView1_DrawC olumnHeader(ByV al sender As Object, ByVal e
As System.Windows. Forms.DrawListV iewColumnHeader EventArgs) Handles
ListView1.DrawC olumnHeader

e.DrawDefault = True

End Sub

Private Sub ListView1_DrawS ubItem(ByVal sender As Object, ByVal e As
System.Windows. Forms.DrawListV iewSubItemEvent Args) Handles
ListView1.DrawS ubItem

e.DrawBackgroun d()

If (e.ItemState And ListViewItemSta tes.Selected) <> 0 Then

e.Graphics.Fill Rectangle(Drawi ng.SystemBrushe s.ActiveCaption ,
e.Bounds)

e.DrawFocusRect angle(e.Bounds)

e.Graphics.Draw String(e.Item.T ext, Me.ListView1.Fo nt,
Drawing.SystemB rushes.Highligh tText, e.Bounds.X, e.Bounds.Y)

Else

e.Graphics.Draw String(e.Item.T ext, Me.ListView1.Fo nt,
Drawing.SystemB rushes.WindowTe xt, e.Bounds.X, e.Bounds.Y)

End If

If e.ColumnIndex = 3 Then

e.Graphics.Draw Image(Me.ImageL ist1.Images(2), e.Bounds.X, e.Bounds.Y)

End If

End Sub

End Class


Nov 21 '05 #1
0 1621

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

Similar topics

1
2297
by: Gary Brown | last post by:
Hi, I just discovered C# w .NET does not support owner draw for TreeViews and ListViews (.NET 1.1). Is there a good workaround? A Google search yielded nothing - or at least nothing easy. Will a future version contain this capability? Thanks, Gary
4
1754
by: Bernie Yaeger | last post by:
I now know how to gather the file type icons and I'm able to use them in a listview. But a listbox does not have a .smallimagelist or .largeimagelist member, so I don't know how to translate that so that I have the icon + the string in a listbox. Is this possible, and if so, can you give me some idea how to go about it. Thanks for any...
0
1650
by: RICKY | last post by:
hi,Does anyone know how to get text longer than a column in a listview in c#? This is easy in c++.you only have to check the LVS_OWNERDRAWFIXED style. then you only have to call the CListCtrl method MyListCtrl.SetItemData(rownumber,0). where rownumber is the item you want the text to spread over all other columns.
1
2821
by: boxim | last post by:
hi all, i need to develop a control to show contact details for companies, in a similar fashion to the way outlook shows contacts. at the moment, i'm cheating using HTML fed from a web server, however i need to now make it use it's own control. what's the best way of doing this? tia
2
2496
by: Eric | last post by:
I implemented owner drawing on the main and context menus of my main form. It works fine. There is also a notify icon control that has a context menu. When the icon is in the status bar, it works perfectly fine when it is double-clicked. However, when I try to initialize the notify icon's context menu as an owner-drawn menu, all the text...
1
1655
by: utkuozan | last post by:
I want to fill an existing ListView with colors and color codes. All color codes are held in an ArrayList as RGB. I have two columns in ListView. I want to fill the ListView with items as the color index as text and having a small thumbnail of the color as Image. Filling the text is quite easy. ( ColorIndexArray .ToString ( ) ) But how can...
0
909
by: paul | last post by:
Hiya eveyone.. does anyone have an example of an owner drawn listview in vb.net.. All the examples I can find are all written in C# Hoep someone can help Cheers....
0
1411
by: Brian Henry | last post by:
I cant seem to remember this one... I have a list view, and im owner drawing the items, i dont want the selection to hide when it loses focus so i have hideselection = false, but when i owner draw this all the items come up gray instead of just the one that is selected when focus is lost, the blue one shows up correctly when it has focus......
0
950
by: Steve Marshall | last post by:
Hi All, I'm working on an owner-drawn combo box which will display multiple columns in the list, either from a table in an associated DataSourse or from delimited strings in the Items collection. It's all going quite well, and was actually easier to achieve than I had expected. But I am seeing one peculiar anomaly when I make a selection...
0
7409
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.