This is a migrated thread and some comments may be shown as answers.

GridViewImageColumn image resizing

3 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 22 Jul 2008, 12:28 AM
Hi,

I am using the RadGridView to display two columns, one is a GridViewImageColumn and another is the GridViewTextBoxColumn.  They are bound to a custom object that is used to display the result of an operation.  Sometimes the message is longer than the column can fit so I have enabled wraptext and implement my own logic to autosize the row height (seeing that this feature was left out).

The trouble with this is that the icon I'm using to display a visual cue is being resized with the row.  It looks awful.  How do I prevent the icon from being resized?

Thanks

Steve

3 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 23 Jul 2008, 07:03 PM
Hi Steve,

You could try setting the ImageLayout property of the image cells to Center in the CellFormatting event handler like in this code:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
        { 
            if (e.CellElement.ColumnInfo is GridViewImageColumn && 
                string.IsNullOrEmpty(((GridViewImageColumn)e.CellElement.ColumnInfo).FieldName)) 
            { 
                int index = (int)e.CellElement.RowInfo.Cells[0].Value - 1; 
                if (index >= 0 && index < this.images.Count) 
                { 
                    e.CellElement.Image = this.images[index]; 
                    e.CellElement.ImageLayout = ImageLayout.Center; 
                } 
            } 
        } 

I hope this help. Don't hesitate to contact me if you have further questions.


Best wishes,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve
Top achievements
Rank 1
answered on 24 Jul 2008, 12:05 AM
Thanks for the help Jordan.

But I'm sorry to say the example doesn't compile.  I perhaps should have mentioned that I'm running Q2 2007.  It seems the ImageLayout and FieldName properties do not exist.

Thanks

Steve
0
Jordan
Telerik team
answered on 25 Jul 2008, 09:45 AM
Hi Steve,

Indeed the example uses features of RadGridView that were added after the Q2 2007 release of RadControls for WinForms. I suggest that you upgrade to the Q2 2008 version that was released yesterday.

Kind regards,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Steve
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Steve
Top achievements
Rank 1
Share this question
or