listview with gridlines

  • Thread starter Joe Abou Jaoude
  • Start date
J

Joe Abou Jaoude

Hi all,
I m trying to have a listview with gridlines. this will make the
listview look like a datagrid. any help would be appreciated.

I have tried to use the samples concerning the owner-drawn list,
unfortunately those samples only deal with listboxes (only one column).
Besides it's like rewriting from scratch a listview control, and i m
sure it will be hard and not as efficient as the already existing
listview control, so i m leaving this as a last option (unless someone
can show me a sample of a listview with owner drawn list)

I tried to inherits from a listview control and override the OnPaint
event (the first obvious choice of course) but that didn't work coz the
onPaint isn't called, apparently it's the form who does the painting of
the control.

I also tried P/Invoke with these constants: (actually i took the code
posted in this newsgroup entiteled "P/Invoke and ListView" posted by
Zahid)
Private Const LVM_GETEXTENDEDLISTVIEWSTYLE As Integer
= &H1037
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Integer
= &H1036
Private Const LVS_EX_GRIDLINES As Integer = &H1


I don't know if that works with other people or if i missed something,
but the result was very disapointing.
the lines were in the middle of the listview items,it's really not
beautiful to see.

so anyone can tell me how can i have a listview with gridlines ?
 
P

Peter Foot [MVP]

There is a sample here to P/Invoke to set gridlines on the control. Be aware
that there is a known issue with the native control where if you have the
list header visible the horizontal gridlines will cut across your text
items - so you'll have to disable the standard list header.
http://www.businessanyplace.net/?p=code#listviewgrid

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
J

Joe Abou Jaoude

hi peter,
i was using the P/invoke as in the sample u gave me, but i didn't know
that the problem was in the list header, so all i have to do now is
remove the list header and put labels docked to the listview to give the
appearance of list headers.

by the way i liked the link u gave me, i checked some sample code there.

thx
 
Joined
Mar 14, 2006
Messages
1
Reaction score
0
ListView with grid

Hi
I also faced the same problem initially.The solution to it is just increase the integer value as u need it.I mean - Private Const LVM_GETEXTENDEDLISTVIEWSTYLE As Integer
> = &H1037 to

Private Const LVM_GETEXTENDEDLISTVIEWSTYLE As Integer
> = &H1039 and see the results. But i suppose the horizontal scrollbar does'nt work in this case.I need some help to make the horiaontal scroll work.How to do that done?

Bye
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top