This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Thumbnaillistview Custom Columns Only

Hi there,

I'm currently evaluating the product.

Have followed your example about creating custom list items. All I want to do is to add a couple of custom columns, is there an easy way to do this, and could someone provide me with some sample code if possible?

Thanks,

Jamie
Hi, Jamie,

If you want just to add some columns you can inherit your custom list item class from the Aurigma.GraphicsMill.WinControls.ThumbnailListItem class and overload GetText method only. You can use the following code snippet as base for your code:
public class CustomThumbItem: Aurigma.GraphicsMill.WinControls.ThumbnailListItem
{
	public CustomThumbItem(string path, string additionalText)
		: base(path)
	{
		_additionalText = additionalText;
	}

	public override string GetText(int textInfoId)
	{
		if (textInfoId != 40 /*your custom TextID*/)
			return base.GetText (textInfoId);
		else 
			return _additionalText;
	}

	private string _additionalText;
}
And, for example, you can use this implementation of the IListItem in such way:
thumbnailListView1.Columns.Add(new Aurigma.GraphicsMill.WinControls.ListColumn(40/*your custom TextID*/, "CustomField", 300, System.Windows.Forms.HorizontalAlignment.Center));

string[] filenames = System.IO.Directory.GetFiles(@"x:\allFormats");
CustomThumbItem[] items = new CustomThumbItem[filenames.Length];

int i = 0;
foreach (string filename in filenames)
{
	string additionalInfo;
	try
	{
		Aurigma.GraphicsMill.Bitmap image = new Aurigma.GraphicsMill.Bitmap(filename);
		additionalInfo = string.Format("Image: {0}x{1} {2}", image.Width, image.Height, image.PixelFormat);
	}
	catch
	{
		additionalInfo = "Cannot load specified file.";
	}

	items[i++] = new CustomThumbItem(filename, additionalInfo);
}

thumbnailListView1.Items.Add(items);