Displaying images in a Flexgrid Cell

Posted by: ehh on 19 December 2021, 9:41 pm EST

  • Posted 19 December 2021, 9:41 pm EST

    Hello,

    Im having some issues getting my grid to scale according to some of my cells, if I display an image in them.
    My grid is using unbound mode, and I can only find an example using a bound grid.




    Best Regads,
    EmilFlexGrid_Images.zip
  • Replied 20 December 2021, 6:45 pm EST

    Hi Emil,
    By setting the FlexGrid default Rows hieght, you may increase the row height and the image would be more clear.
    Please refer to the following code snippet for reference:
    grid.Rows.DefaultSize = 100;


    Also, please set the image width and height to 100% so that the image can be fit within the cell. It would be better if you may provide the cell size image for more clarity to the user,

    Regards,
    Manish Gupta
  • Marked as Answer

    Replied 20 December 2021, 7:11 pm EST

    Hello Manish,

    Thanks for the quick answer, this is not exactly what im looking for, but you pointed me in the right direction.
    I ended up checking in my cell factory, in the PrepareCellStyle, if the cell have an image value, and then set the minheight of that specific row.

    public override void PrepareCellStyle(GridCellType cellType, GridCellRange range, C1Style style, C1Thickness internalBorders)
    {
    base.PrepareCellStyle(cellType, range, style, internalBorders);
    if (cellType == GridCellType.Cell || cellType == GridCellType.RowHeader)
    {
    Cell cell = (Cell)Grid.Cells[range.Row, range.Column];
    if (cell.BackColor != null)
    {
    Color col = Color.FromName(cell.BackColor);
    style.BackgroundColor = C1Color.FromARGB(col.A, col.R, col.G, col.B);
    }
    if (!string.IsNullOrEmpty(cell.Image))
    {
    Grid.Rows[range.Row].MinHeight = 200;
    }
    }
    }


    Best Regards,
    Emil
  • Replied 21 December 2021, 1:11 pm EST

    Hi Emil,
    Thank you for notifying us that your issue has been resolved with the suggestion that we gave.

    Regards,
    Manish Gupta
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels