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
390
Can't resize Image Col
posted

I've added an image col to my wingrid and the col is much larger than the image itself.  I'm trying to resize it but I get an error.

        
private void GridSchemaErrors_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            UltraGridLayout layout = e.Layout;
            UltraGridBand band = layout.Bands[0];
            UltraGridColumn imageColumn = band.Columns.Add("ImageCol");
            imageColumn.Header.VisiblePosition = 0;
            gridSchemaErrors.DisplayLayout.PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand,
                    AutoResizeColumnWidthOptions.All);
            imageColumn.DataType = typeof(Image);
            imageColumn.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Image;
            
        }

Then I set the image

        private void GridSchemaErrors_InitializeRow(object sender, InitializeRowEventArgs e)
        {
            if (e.Row.Cells["Status"].Value == "OK")
            {
                e.Row.Cells["ImageCol"].Value = Image.FromFile(".//Images//Check.jpg"); ;
            }
            else if (e.Row.Cells["Status"].Value == "Failed")
            {
                e.Row.Cells["ImageCol"].Value = Image.FromFile(".//Images//X.jpg");
            }
        }

I get this runtime error:

System.InvalidCastException: 'Object must implement IConvertible.'

The error happens when it sets the image in InitializeRow..