Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
Setting Icon - OutOfMemoryException or Blue Halo
posted

version 7.3 Hotfix 1041

I have a custom control that is a UltraListView inside of a UltraGroupBox. When I try to loop through the items to create and assign them an icon from a resource, I get an OutOfMemoryException when I add them to the UltraListView's collection. If I instead add them to an ImageList and use that, I get an ugly blue halo around the icon. Using the same ImageList elsewhere does not result in that. Any suggestions?

 

/// <summary>

/// Initializes a new instance of the <see cref="TaskMenuPanel"/> class.

/// </summary>

/// <param name="fkDesktopSection">The primary key of the parent section.</param>

public TaskMenuPanel( int fkDesktopSection ) : this( ) {

this.fkDesktopSection = fkDesktopSection;

if( this.fkDesktopSection == 0 ) {

return;

}

this.items = DesktopItemBroker.GetListForSection( this.fkDesktopSection );

var list = new List<UltraListViewItem>( this.items.Count );

var taskMenuImages = EnumHelper.EnumToList<ImageCollections.TaskMenuImage>( );

for( var i = 0; i < this.items.Count; i++ ) {

var item = new UltraListViewItem( items[ i ].SideLink );

item.Value = items[ i ].LinkText;

item.Appearance.Image = ImageHelper.GetFromResource( "Images32", StringEnum.GetDescriptionValue( taskMenuImages[ i ] ) );

list.Add( item );

}

this.listView.Items.AddRange( list.ToArray( ) );

}