Print Page | Close Window

Add Icon to ReportRecordItem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=7328
Printed Date: 05 July 2025 at 3:40am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Add Icon to ReportRecordItem
Posted By: Shawshank
Subject: Add Icon to ReportRecordItem
Date Posted: 07 June 2007 at 4:00pm
I have added an icon to the ImageManager control. I then assigned the ImageManager to the .Icons property of the ReportControl. But when I add a ReportRecordItem and assign the .Icon property to the image value of the ImageManager the icon does not appear. Yet, when I assign the icon to a CommandBarControl the icon appears as expected. This tells me 1) that I have successfully added the icon to the ImageManager and 2) that the icon is valid and 3) that I am assigning the proper icon value to the .Icon property. What would cause the ReportRecordItem to not show the icon where the CommandBarControl will? Here is my code:
 
lRet& = CLSIDFromString(StrPtr("{4D36E977-E325-11CE-BFC1-08002BE10318}"), lGUID)
 
lRet& = SetupDiLoadClassIcon(lGUID, lIcon&, lIdx&)
 
'I now have the icon handle in lIcon&
'Assign to ImageManager
 
Me.ImageManager1.Icons.AddIcon lIcon&, 1, xtpImageNormal
 
'Assign ImageManager to the .Icons property of RC
 
Set Me.ReportControl1.Icons = Me.ImageManager1.Icons
 
'Create ReportRecordItem and assign the icon
 
Set Record = Me.ReportControl1.Records.Add()
Set Item = Record.AddItem("Test!")
 
Item.Icon = 1
 
I would expect the icon to appear on the ReportRecordItem but fails to. Assigning the icon to the CommandBarControl works great. What could I be doing wrong?
 
Shawshank



Replies:
Posted By: jcollier
Date Posted: 08 June 2007 at 12:05pm
I am doing this also with success.  With the exception of the fact that I am adding the images to the ImageManager at design time I only have the following two differences:

Instead of:

Set Me.ReportControl1.Icons = Me.ImageManager1.Icons

Try:

Me.ReportControl1.Icons = Me.ImageManager1.Icons

And I am not assigning a value to the item prior to Item.Icon = 1




Posted By: Shawshank
Date Posted: 08 June 2007 at 12:56pm
I have tried doing it both ways; with the Set statement and without. In both cases I do not have the icon showing in the ReportControl. It does, however, work with the CommandBarControl in either case.
 
Also, I have tried adding the icon to the ImageManager before assigning the ImageManager and after assignment.
 
Shawshank


Posted By: jcollier
Date Posted: 08 June 2007 at 1:02pm
Hm.  Is your icon 16x16 or larger?  Mine are 16x16

My column is set up as follows:

Set Column = rpt.Columns.Add(COL_DELETESTEP, "", 3, True)
            Column.Editable = True

Then I fill and populate the report:

Set Item = Record.AddItem("")
Item.Icon = ID_DELETESTEP
rpt.populate


Posted By: Shawshank
Date Posted: 08 June 2007 at 1:14pm
Yes, my icon is larger than 16x16. Does this then mean that the CommandBarControl can scale an icon down and the ReportControl cannot?
 
Shawshank


Posted By: Shawshank
Date Posted: 08 June 2007 at 2:51pm
I discovered a very easy, succinct solution. Instead of adding the icons to the ImageManager or a MS ImageList control I instead added them to the Icon collection of the ReportControl itself. This had the benefit of allowing me to add large icons and then have them scaled down to 16x16 size when assigned to a ReportRepordItem.
 
Shawshank


Posted By: jcollier
Date Posted: 08 June 2007 at 2:53pm
Cool.  I never even thought of that.  I might have to try it also.

Thanks!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net