Home Forums WinForms controls Xceed Grid for WinForms Resize of Imageviewer? Reply To: Resize of Imageviewer?

User (Old forums)
Member
Post count: 23064

I don’t know how to do this, without creating a CellViewer. Maybe you could create a custom CellViewer that is a subclass of GridImageBox, and that overrides the PaintCellValue method. Try this (untested) code:<code>public class MyGridImageBox : GridImageBox, ICellViewer {
int ICellViewer.GetFittedHeight(Cell cell, AutoHeightMode mode) {
try {
Image image = GetImage(cell.Value);
if (image != null) return image.Height;
else return -1;
} catch { return -1; }
}
int ICellViewer.GetFittedWidth(Cell cell) {
try {
Image image = GetImage(cell.Value);
if (image != null) return image.Width;
else return -1;
} catch { return -1; }
}
bool ICellViewer.PaintCellValue(GridPaintEventArgs e, Cell cell) {
try {
Image image = GetImage(cell.Value);
if (image != null) {
e.Graphics.DrawImage(image, 0, 0);
return true;
} else return false;
} catch { return false; }
}
}</code>

Imported from legacy forums. Posted by Tommy (had 312 views)