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

how to add icons

1 Answer 288 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Prashant
Top achievements
Rank 1
Prashant asked on 22 Mar 2014, 01:18 AM
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]

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Mar 2014, 03:22 PM
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.

 
Tags
PropertyGrid
Asked by
Prashant
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or