Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsI need to create a listview that contains a question in the first column, and an answer selection in the second column. The answer column values need to be drawn as buttons so that a user can answer by clicking the appropriate button. I just can't work out how to make the listview owner drawn, and allow my application to draw to the items.
I tried getting the listview to be custom drawn using this code... (Form designer generated code removed)
Imports System.Runtime.InteropServ
Public Class Form1
Inherits System.Windows.Forms.Form
Private Delegate Function DrawProc(ByVal lParam As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const DWL_MSGRESULT = 0
Public Const DWL_DLGPROC = 4
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Long, ByVal dwNewLong As DrawProc) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListView1.Items.Add("Test"
ListView1.Items.Add("Test 2")
ListView1.Items.Add("Test 3")
ListView1.Items.Add("Test 4")
End Sub
Private Function CustomDrawProc(ByVal lparam As Long) As Long
' Can't seem to get any messages coming in here
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SetWindowLong(ListView1.Ha
End Sub
End Class
But no messages ever seem to be passed to the CustomDrawProc.
I've found plenty of examples of this in VC++ 6, but none in .Net. I am quite new to programming in .Net and any help and guidance on this would be much appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: TheLearnedOnePosted on 2004-02-04 at 12:38:26ID: 10274650
Comments are available to members only. Sign up or Log in to view these comments.