Displaying Images in a grid view

4 posts, 0 answers
  1. Wayne Thompson
    Wayne Thompson avatar
    3 posts
    Member since:
    Jul 2009

    Posted 13 Oct 2009 Link to this post

    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

  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 13 Oct 2009 Link to this post

    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.
  3. DevCraft banner
  4. Wayne Thompson
    Wayne Thompson avatar
    3 posts
    Member since:
    Jul 2009

    Posted 13 Oct 2009 Link to this post

    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.
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 15 Oct 2009 Link to this post

    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.
Back to Top