how to add icons

2 posts, 0 answers
  1. Prashant
    Prashant avatar
    3 posts
    Member since:
    Jan 2013

    Posted 21 Mar 2014 Link to this post

    Hi,
    How can I add icons to Category panel in property grid.

    Also, how to add icon to propertyentry element in Grid.  

    [-]  [icon]   Appearance (category tab)
           [some icon_1]  Color             |   Red
           [some icon_2]  Orientation   |   Left
                                      Preview       |    [ Preview image]

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 25 Mar 2014 Link to this post

    Hello Prashant,

    Thank you for contacting Telerik Support.

    It is appropriate to use the ItemFormatting event and set the desired image for the specific PropertyGridItemElement:
    public Form1()
    {
        InitializeComponent();
     
        radPropertyGrid1.PropertySort = PropertySort.Categorized;
        radPropertyGrid1.SelectedObject = new Item(1234, "Custom title", "Description", 9834657);
        radPropertyGrid1.ItemFormatting += radPropertyGrid1_ItemFormatting;
     
        radPropertyGrid1.PropertyGridElement.PropertyTableElement.ItemHeight = 50;
    }
     
    private void radPropertyGrid1_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e)
    {
        PropertyGridItemElement item = e.VisualElement as PropertyGridItemElement;
        if (item != null && e.Item.Name=="Photo" )
        {
            item.ValueElement.DrawText = false;
            item.ValueElement.Image = Properties.Resources.AndrewFuller;
            item.ValueElement.ImageLayout = ImageLayout.Zoom;
        }       
    }
     
    public class Item
    {
        [Category("Category1")]
        public int Id { get; set; }
     
        [Category("Category2")]
        public string Title { get; set; }
     
        [Category("Category2")]
        public string Description { get; set; }
     
        [Category("Category1")]
        public int BarCode { get; set; }
     
        public Image Photo { get; set; }
     
        public Item(int id, string title, string description, int barCode)
        {
            this.Id = id;
            this.Title = title;
            this.Description = description;
            this.BarCode = barCode;
            this.Photo=Properties.Resources.AndrewFuller;
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Desislava
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top