Insert icon on GridViewCommand

3 posts, 1 answers
  1. Flávio
    Flávio avatar
    16 posts
    Member since:
    Jun 2011

    Posted 05 Sep 2011 Link to this post

    Hi,

      I'd like know how to do set a icon on GridViewCommand?
    Example attached!

    Thanks attention!
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 08 Sep 2011 Link to this post

    Hello Flávio,

    Thank you for writing.

    You should handle the CellFormatting event to achieve the desired functionality. Here is an example:

    private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridCommandCellElement commandCell = e.CellElement as GridCommandCellElement;
        if (commandCell != null)
        {
            commandCell.CommandButton.Image = Image.FromFile(@"C:\Users\stefanov\Documents\16x16\boldhs.png");
            commandCell.CommandButton.ImageAlignment = ContentAlignment.MiddleCenter;
        }
    }

    For more information about this event, please refer to the following help article: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.

    Greetings,
    Stefan
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Flávio
    Flávio avatar
    16 posts
    Member since:
    Jun 2011

    Posted 08 Sep 2011 Link to this post

    Hi Stefan,

       Problem solved!

    Thanks attention!
Back to Top