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

Displaying Images in a grid view

3 Answers 194 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Wayne Thompson
Top achievements
Rank 1
Wayne Thompson asked on 13 Oct 2009, 06:22 AM
Can anyone tell me how to display images in a radGridview cell. The data is basically going to be a boolean so there just needs to be an image for true and a different one for false.


we also have a requirement to display a combo box with 3 different images as options in one of the cells. I have ready achieved this with text alone but how would i insert an image into a combo box.

thanks

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 13 Oct 2009, 02:09 PM
Hello Wayne Thompson,

We have recently introduced a new column type called GridViewImageColumn which allows you to easily display and image in RadGridView. To use this column you should get one of our latest internal builds but if that is not convenient you could define a CellTemplate to achieve the same result:

<telerikGrid:RadGridView x:Name="radGridView" AutoGenerateColumns="False">
    <telerikGrid:RadGridView.Columns>
        <!-- Built-in image coumn -->
        <telerikGrid:GridViewImageColumn 
            Header="XAML-Defined Image Column" 
            Width="Auto" DataMemberBinding="{Binding MyImageUrlProperty}">
        </telerikGrid:GridViewImageColumn>
        <!-- Manually-built image column -->
        <telerikGrid:GridViewColumn>
            <telerikGrid:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding MyImageUrlProperty}"/>
                </DataTemplate>
            </telerikGrid:GridViewColumn.CellTemplate>
        </telerikGrid:GridViewColumn>
    </telerikGrid:RadGridView.Columns>
</telerikGrid:RadGridView>

Could you please provide more information about your combobox column scenario? Do the images that you would like to display in the combo correspond to data values, similarly to the true-or-false column? Or are they just images like "option1.jpg", "option2,jpg" etc?

Best wishes,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wayne Thompson
Top achievements
Rank 1
answered on 14 Oct 2009, 02:51 AM
I have a need for 3 different columns. For all columns the image will be an icon relating to status.

1) Status column with a combo box. Combo box has 3 options (Approved, Pending, Requires Attention) each of which is an image.

2) a column of which the datasource is a boolean. The column displays a red image for false and a green image for true.

3) again a boolean that displays an alert icon if true and nothing if false.
0
Milan
Telerik team
answered on 15 Oct 2009, 04:46 PM
Hi Wayne Thompson,

You can achieve 2 and 3 by using our GridViewImageColumn and follow the approach that I have mentioned in my previous post. 1 needs a bit more XAML and for that reason I have created a sample application that demonstrates how you can implement the required functionality.

The approach is similar to the first one in that we again use a converter to convert a status text (Approved, Pending, etc) to its corresponding image.

Hope the code is helpful.

Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Wayne Thompson
Top achievements
Rank 1
Answers by
Milan
Telerik team
Wayne Thompson
Top achievements
Rank 1
Share this question
or