We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to insert a combobox CustomEditor for a property that is a foreign key ID

Thread ID:

Created:

Updated:

Platform:

Replies:

125555 Aug 24,2016 03:48 PM UTC Aug 25,2016 11:06 AM UTC WPF 1
loading
Tags: PropertyGrid
Silvio
Asked On August 24, 2016 03:48 PM UTC

Hi,

I have a PropertyGrid that edits an object that has an int property that represents a foreign key to a particular list of objects.
Let's say for example that the objects referenced by this foreign key have this type:

class Article
{

public int ID {get; set;}

public string Code {get; set;}

}

Let also say that I have a repository that returns the list of all articles:

IEnumerable<Article> Articles
{
get;
}

Suppose the object passed to the ProperyGrid has a property like this:

int ArticleID {get; set;}

How is it possibile to change the default behaviour of PropertyGrid on property named "ArticledID"?

I don't want, in fact, an integer textbox edit, but instead I'd like to a have a ComboBox populated by "Articles" repository property, showing the "Code" property as Display property but using the "ID" property as Value property.

Thank you in advance.

Silvio

Vinothini [Syncfusion]
Replied On August 25, 2016 11:06 AM UTC

Hi Silvio, 

Thank you for contacting Syncfusion support. 

The ComboBox can be added to the Property grid using the CustomEditorCollection property. We need to implement a Custom editor with ITypeInterface. Please refer the code example for adding ComboBox in ArticleID property. 

[C#] 

 
pgrid.SelectedObject = new Article(); 
CustomEditor editor = new CustomEditor(); 
editor.Editor = new ComboEditor(); 
editor.Properties.Add("ArticleID"); 
this.pgrid.CustomEditorCollection.Add(editor); 
pgrid.RefreshPropertygrid(); 



We have prepared sample for the sample which is available in the below location. 


Regards, 
Vinothini.R 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;