Display a description value in propertygriditem

4 posts, 0 answers
  1. Maurice
    Maurice avatar
    3 posts
    Member since:
    Dec 2014

    Posted 30 Jan Link to this post

    I have the following

    class LookupItem

    {

         public Guid Id {get;set;}

         public string Description {get;set;}

    }

    class SomeOtherClass

    {

      public int Key {get;set;}

      public Guid LookupItemId {get;set;}

      public string SomeProperty {get;set;}

    }

     

    Now.

    The LookupItem class will be a part of a collection (or lookup list) e.g. List<LookupItem>

    The SomeOtherClass is the selectedObject of the propertygrid

    I have looked through the samples such as https://docs.telerik.com/devtools/winforms/knowledge-base/propertygrid-dropdown-editor

    and whilst I can get the combobox or RadMultiColumnComboBox to display when editing, I need to be able to show the description value of the selected lookupitem in the propertygrid item. Currently its displaying the LookupItem.Id which is a Guid.

     

    Any ideas? The simplest will suffice

  2. Maurice
    Maurice avatar
    3 posts
    Member since:
    Dec 2014

    Posted 31 Jan Link to this post

    Heres the effect Im looking for
  3. Maurice
    Maurice avatar
    3 posts
    Member since:
    Dec 2014

    Posted 31 Jan in reply to Maurice Link to this post

    Im looking to get a lookuplist that has 2 or more columns working in the property grid.

    Thank you.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3217 posts

    Posted 01 Feb Link to this post

    Hello, Maurice,       

    The easiest solution that I can suggest is to handle the ItemFormatting and change the text for the value element:
     
    private void radPropertyGrid1_ItemFormatting(object sender, Telerik.WinControls.UI.PropertyGridItemFormattingEventArgs e)
    {
        if (e.Item.Label == "property name")
        {
            PropertyGridItemElement itemElement = e.VisualElement as PropertyGridItemElement;
            if (itemElement != null)
            {
                itemElement.ValueElement.Text = "desired text to display";
            }
        }
    }

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top