Author Topic: ListView Control (6.0)  (Read 8523 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« 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 ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #1 on: April 11, 2005, 05:31:26 PM »
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« Reply #2 on: April 11, 2005, 06:24:26 PM »
No go ...
According to MSDN ...
Quote

Returns or sets a value that specifies the image used for the ColumnHeader object when the View property is set to lvwReport
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #3 on: April 11, 2005, 06:27:44 PM »
Docs are wrong, I've done this Keith.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« Reply #4 on: April 11, 2005, 06:35:11 PM »
I just put the code in the form and it does not work ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #5 on: April 11, 2005, 06:38:53 PM »
Grrr ... I know I've done this.

I'll be you $50 I can add column specific icons without subclassing etc.

:cheesy:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« Reply #6 on: April 11, 2005, 06:42:12 PM »
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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #7 on: April 11, 2005, 06:45:30 PM »
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).
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #8 on: April 11, 2005, 06:58:47 PM »
Ok ... just a quick example.

This code will produce this:



Edit: Added CheckBox toggle to code and simplified per next post.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #9 on: April 11, 2005, 07:08:58 PM »
I just tried something else ...

if you replace the for loop in the example I provide with this:

Code: [Select]
       ...
        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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #10 on: April 11, 2005, 07:21:36 PM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« Reply #11 on: April 11, 2005, 07:49:30 PM »
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 ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« Reply #12 on: April 11, 2005, 08:07:41 PM »
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 ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ListView Control (6.0)
« Reply #13 on: April 11, 2005, 08:50:37 PM »
Quote from: Keith
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.

Quote from: Keith
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
ListView Control (6.0)
« Reply #14 on: April 11, 2005, 08:52:41 PM »
I should be able to do that easily enough.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie