Home Forums WinForms controls Xceed Grid for WinForms Resize of Imageviewer?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13831 |

    I have a column with an imageviewer. Unfortunately the image is resized if the row takes 2 or 3 lines instead of just 1. How could I set the width and height of the icons so the icon will have the same size as it is stored?

    Imported from legacy forums. Posted by Kai (had 2997 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi all,

    no idea or too complicated to understand my request? Thanks!

    Imported from legacy forums. Posted by Kai (had 343 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    Hi Tommy,

    yes, it works! Thanks a lot!

    Imported from legacy forums. Posted by Kai (had 4021 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.