Where is the listview control?

Where is the listview control?

Post by SpreadTooT » Sat, 14 Jul 2007 09:41:55


I'm trying to add a listview to my project because the listbox doesn't
have a horizontal scrollbar.
When I try to add the component I don't know which Microsoft object to
add....

Am I going about this in the right way?
 
 
 

Where is the listview control?

Post by Dag Sund » Sat, 14 Jul 2007 09:57:34


"Microsoft Windows Common Controls 6.0 (SP6)"

--
Dag.

 
 
 

Where is the listview control?

Post by SpreadTooT » Sat, 14 Jul 2007 10:27:18


Ok so its not exactly a plug and play replacement for the listbox...
I just want to add a line of text to it...
How?
 
 
 

Where is the listview control?

Post by Dag Sund » Sat, 14 Jul 2007 11:28:50


Oh no... It only remotely resembles the listbox when it is in
report mode. It is infinitely more powerful and versatile than
a Listbox.


Put a listview on a form.and add this, for a basic example:
Private Sub Form_Load()

Dim itmX As ListItem

ListView1.View = lvwReport
ListView1.FullRowSelect = True
ListView1.GridLines = True

ListView1.Width = 4045

ListView1.ColumnHeaders.Add , "keyName", "Name", 2000, lvwColumnLeft
ListView1.ColumnHeaders.Add , "keyPhone", "Phone", 1500, lvwColumnCenter
ListView1.ColumnHeaders.Add , "keyAge", "Age", 500, lvwColumnRight

Set itmX = ListView1.ListItems.Add(, , "Dag Sunde")
itmX.SubItems(1) = "(+47) 926 13 932"
itmX.SubItems(2) = "42"

Set itmX = ListView1.ListItems.Add(, , "John Smith")
itmX.SubItems(1) = "(+1) 6666 12345"
itmX.SubItems(2) = "74"

Set itmX = ListView1.ListItems.Add(, , "John Doe")
itmX.SubItems(1) = "(+45) 888 23 968"
itmX.SubItems(2) = "34"

End Sub

Most of the properties set in code here can be set at design-time...

--
Dag.
 
 
 

Where is the listview control?

Post by SpreadTooT » Sat, 14 Jul 2007 13:03:41


Thank you this is a helpfull example. I would be setting columns to
one (1)
However i don't see the property to enable a horizontal and vertical
scroll bar.
(At least not in visual basic)
 
 
 

Where is the listview control?

Post by SpreadTooT » Sat, 14 Jul 2007 13:28:51

> ListView1.View = lvwReport

Has lvwReport been depricated?
What does this this do?
 
 
 

Where is the listview control?

Post by VB M » Sat, 14 Jul 2007 17:04:38

SpreadTooThin < XXXX@XXXXX.COM >'s wild thoughts were
released on Thu, 12 Jul 2007 17:41:55 -0700 bearing the
following fruit:


But it can.

http://www.yqcomputer.com/


https://mvp.support.microsoft.com/profile/Jan.Hyde
 
 
 

Where is the listview control?

Post by SpreadTooT » Sat, 14 Jul 2007 23:26:08

On Jul 13, 2:04 am, "Jan Hyde (VB MVP)"


Thank you.
I notice that it is calling drawtext. Is that to physically display
the list or is just to calculate the text bounding box? If it's
drawing the text then isn't that a bit of a waste of processor?
If so shouldn't there be a way to calculate the bounding box without
having to physically draw the text? Isn't the object going to want to
update itself when ever you add an item to the list?
I guess I'm trying to avoid updating the display more often then is
necessary.
 
 
 

Where is the listview control?

Post by VB M » Sat, 14 Jul 2007 23:37:02

SpreadTooThin < XXXX@XXXXX.COM >'s wild thoughts were
released on Fri, 13 Jul 2007 07:26:08 -0700 bearing the
following fruit:



It's only doing that to determine the longest item. How you
wish to achieve the same is up to you. The important part of
that article was to show how you can set a horizontal
scrollbar.

For example you might find the longest item as your adding
items the the list, then you only need to determine the
width once.



https://mvp.support.microsoft.com/profile/Jan.Hyde
 
 
 

Where is the listview control?

Post by SpreadTooT » Sat, 14 Jul 2007 23:54:38

On Jul 13, 8:37 am, "Jan Hyde (VB MVP)"


Your absolutly right, but is drawing the text the only way to find out
how large it is?
If I draw it once during add (and keep track of the previous maxiumum
width) to determine if I have a new maximum width then won't the
listview also try to redraw itself? I want to avoid flicker if you
know what i mean.
 
 
 

Where is the listview control?

Post by Ivar » Sun, 15 Jul 2007 16:54:03


Copied from MSDN:

DT_CALCRECT Parameter Determines the width and height of the rectangle. If
there are multiple lines of text, DrawText uses the width of the rectangle
pointed to by the lpRect parameter and extends the base of the rectangle to
bound the last line of text. If there is only one line of text, DrawText
modifies the right side of the rectangle so that it bounds the last
character in the line. In either case, DrawText returns the height of the
formatted text but does not draw the text.
 
 
 

Where is the listview control?

Post by VB M » Tue, 17 Jul 2007 17:05:05

SpreadTooThin < XXXX@XXXXX.COM >'s wild thoughts were
released on Fri, 13 Jul 2007 14:54:38 -0000 bearing the
following fruit:




Listview? I though we were talking about a listbox. I
listview has a horixantal scrollbar.

J
https://mvp.support.microsoft.com/profile/Jan.Hyde
 
 
 

Where is the listview control?

Post by SpreadTooT » Wed, 18 Jul 2007 02:13:09

On Jul 16, 2:05 am, "Jan Hyde (VB MVP)"




Listbox doesn't have a horizontal scrollbar.
 
 
 

Where is the listview control?

Post by Mike Willi » Wed, 18 Jul 2007 05:29:15


No, but you can give it one. Did you not see Jan Hyde's post in this
thread, where he posted the following link:

http://www.yqcomputer.com/

Check it out.

Mike
 
 
 

Where is the listview control?

Post by VB M » Thu, 19 Jul 2007 17:04:10

SpreadTooThin < XXXX@XXXXX.COM >'s wild thoughts were
released on Mon, 16 Jul 2007 10:13:09 -0700 bearing the
following fruit:





I know, but you say listbox on minute and listview then
next. They are two entirely different controls.


https://mvp.support.microsoft.com/profile/Jan.Hyde