TheSwamp
Code Red => VB(A) => Topic started by: Keith™ on April 11, 2005, 05:08:29 PM
-
Ok, all of you API gurus .... (I hope there are some)
I want to mimic something the layer dialog does ... I want to place an icon image in the second and/or third column in a ListView control and have NO icon in the first column. Then I want the listview control to act independently on each "cell" as it were in the list. Click on column 2 and fire an event for the "selected" column, but don't fire an event for the first column or third column.
Any takers, or should I keep using my trial and error methods ...
-
Look at the ReportIcon property.
e.g. Assuming ListView1 (report view) has an associated image collection with three 16x16 icons, with keys "icon0", "icon1" and "icon2" ...
Dim item As ListItem
Set item = ListView1.Add(, , "Field 0", , "icon0")
item.SubItems(1) = "Field 1"
item.ListSubItems.item(1).ReportIcon = "icon1"
item.SubItems(2) = "Field 2"
item.ListSubItems.item(2).ReportIcon = "icon2"
I'm drawing this from memory and did it blind so you may have to play with it a bit, but the basic info should be correct.
-
No go ...
According to MSDN ...
Returns or sets a value that specifies the image used for the ColumnHeader object when the View property is set to lvwReport
-
Docs are wrong, I've done this Keith.
-
I just put the code in the form and it does not work ...
-
Grrr ... I know I've done this.
I'll be you $50 I can add column specific icons without subclassing etc.
:cheesy:
-
Please show me ... because I have been trying my best to keep from subclassing ... you would think that the API would allow you to do it, but I have not found the right combination. I did find a bit of code, but it explicitly said it did not work with the SP3 release (6.0) and I need the 6.0 because I want the checkboxes for the listview.
-
At home I'm running SP6 but at work (because I just changed PCs) I'm running the original Visual Studio 6 (no service pack). I'll see what I can do (already started it for you).
-
Ok ... just a quick example.
This code (http://www.theswamp.org/lilly_pond/mp/files/ForKeith.zip?nossi=1) will produce this:
(http://www.theswamp.org/screens/mp/icons.png)
Edit: Added CheckBox toggle to code and simplified per next post.
-
I just tried something else ...
if you replace the for loop in the example I provide with this:
...
For i = 1 To 20
Set item = .ListItems.Add(, , "Record" & Str(i))
Call item.ListSubItems.Add(, , , "one")
Call item.ListSubItems.Add(, , , "two")
Call item.ListSubItems.Add(, , , "three")
Next i
...
You'll find it works too.
Obviously in your working code you'll want to use indexes etc. (columnheader objects as well as listitems, and subitems) -- I didn't bother for this little exercise.
-
And FYI ... (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cmctl198/html/vbmthAddMethod(ListSubItemsCollection).asp)
Cheers.
-
Now, do you want to know something funny .... I used your code and it works just fine, BUT if I use the EXACT syntax with my ListView control, it does not work. The FRX indicates they are the exact controls... I guess I will paste yours into my form and use it ... go figure ...
I'll let you know when I get it fixed up ...
-
Ah ... I found the culprit ... an errant API call changing the extended ListView settings ... I edited the call and voila .. it now works fine ...
Thanks for being patient with me ...
-
Ah ... I found the culprit ... an errant API call changing the extended ListView settings ... I edited the call and voila .. it now works fine ...
Thanks for being patient with me ...
My pleasure, glad it's working for you.
Then I want the listview control to act independently on each "cell" as it were in the list. Click on column 2 and fire an event for the "selected" column, but don't fire an event for the first column or third column.
You'll have to roll yer own code for this portion if I'm not mistaken. i.e. Use the ItemClick event to trap which ListItem was clicked, use the MouseDown or MouseUp event to trap the x coordinate of the mouse and compare against the widths of the ColumnHeaders to determine which SubItem actually took the hit. Hope that made sense.
-
I should be able to do that easily enough.
-
An understatement; I expect you'll pen something quite elegant.
-
What ever came of this Keith, were you able to do what you wanted?
-
Indeed ... thanks for asking ...
-
Good to hear.
Any generic code you can share with the rest of the class?
:)
-
Not at this point, but if I get some time I will see if I can extract a bit and post it. This was for a client so I have to be very careful about dissemination of code.
-
Of course, I'd never ask you breach those boundaries.
I was just thinking about the code (or alternative technique) that corresponded to --
"You'll have to roll yer own code for this portion if I'm not mistaken. i.e. Use the ItemClick event to trap which ListItem was clicked, use the MouseDown or MouseUp event to trap the x coordinate of the mouse and compare against the widths of the ColumnHeaders to determine which SubItem actually took the hit."
Would prove interesting to see how you implemented it (or as noted, the alternative technique you may have used).
Of course, if that's what the client paid for then just ignore the inquiry.
Cheers.
:)
-
What I finally did was a mouse down event with an x coordinate mask, then use the selected row to filter the actual item selected.