Property editor

Using a class, how can we add dropdown for values selection in the property editor? 
I would like also to add a file browser that can hold a path to a particular filefile. How can I accomplish this?



11 Replies

NG Naganathan Ganesh Babu Syncfusion Team February 5, 2018 08:47 AM UTC

Hi Allen,  
 
By default, the System framework can automatically display dropdown/file browser to selecting the values when we bind the Enum/OpenDialog related properties into the PropertyEditor. So, we suggest you to just bind the selected object’s (i.e. implemented class object in your project) properties into the property editor and automatically the property editor can bind the selection values as like as dropdown, file browser etc based on the implemented properties.  
 
Please refer to the below attached sample. 
 
Sample: 
 
 
Video: 
 
 
Note: 
In above sample, we have customized diagram’s BitmapNode class and added the two new properties (i.e. 1. Enum object 2. Bitmap object property). The enum property as bind as DropDown and NewImage property as bind as file browser into the propertyEditor. 
 
Regards,  
 
Naganathan K G  
 



NG Naganathan Ganesh Babu Syncfusion Team February 5, 2018 09:39 AM UTC

Hi Allen,  
 
Please ignore our previous update. 
 
Please confirm us whether your requirement is to bind the object without diagram dependency into the propertyEditor manually in your project? If yes, we suggest you to use PropertyEditor’s “PropertyGrid” to property to bind the object which are you want display in property editor based on your project. Because, the PropertyEditor’s PropertyGrid is implemented/used from the System framework. 
 
Also, the System framework can automatically display the Enum object as dropdown and OpenDialog related object as file browser to selecting the values when we bind the Enum/OpenDialog related properties into the PropertyEditor.  
 
 
Sample: 
 
 
Video: 
 
 
Note: 
In above sample, we have added the two new properties (i.e. 1. Enum object 2. Bitmap object property). The enum property as bind as DropDown and NewImage property as bind as file browser into the propertyEditor. 
 
Regards,  
 
Naganathan K G  
 



AL Allen February 5, 2018 02:25 PM UTC

Thank you so much, Naganathan
I can see the list well.  Just one more thing. I tried to seralize & deseralize the List but I got stacked.  
Further more, when the item in the list is selected, I would like to update a value in the property editor.  
As to the file browser button (as diagram dependant), I would like to have it in the propertyEditor.  Would you have an example?  The example you provided doesn't place the file path


AL Allen February 5, 2018 03:08 PM UTC

I mean, if I select an item in the dropdown, another value in the property editor will be changed. For instance, i have a dropdown list in the property editor that contains images of 3 cars. I have also a Price value in the property grid. Each car image is related to the price value. Let's say I have img1, img2, img3 in the cartype. If I chose img1, the vale if Price in the property editor changes to say 20000,, if img2 is chosen, Price value becoes 30000,, etc. 

Since this information is linked to a diagram, I would like to serialize/deserialize the Enum

Can you help me on this part?




NG Naganathan Ganesh Babu Syncfusion Team February 6, 2018 09:07 AM UTC

Hi Allen, 
 
I can see the list well.  Just one more thing. I tried to seralize & deseralize the List but I got stacked.   
 
Since this information is linked to a diagram, I would like to serialize/deserialize the Enum 
We suggest you to add serialization entries for your custom properties in your custom symbol. Please refer the below code snippet to achieve your requirement. 
 
''' <summary> 
''' Serialization constructor for the MySymbol class. 
''' </summary> 
''' <param name="info">Serialization state information</param> 
''' <param name="context">Streaming context information</param> 
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) 
            MyBase.New(info, context) 
            For Each entry As SerializationEntry In info 
                Select Case entry.Name 
                    Case "Car" 
                        m_car = CType(entry.Value, Cars) 
                    Case "Price" 
                        m_price = entry.Value.ToString() 
                End Select 
            Next entry 
        End Sub 
 
Protected Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) 
                        info.AddValue("Car", m_car) 
            info.AddValue("Price", m_price) 
                        MyBase.GetObjectData(info, context) 
End Sub 
As to the file browser button (as diagram dependant), I would like to have it in the propertyEditor.  Would you have an example?  The example you provided doesn't place the file path 
While adding custom property in customized class, we suggest you to add System “EditorAttribute()” with  the parameter as “GetType(System.Windows.Forms.Design.FileNameEditor), GetType(System.Drawing.Design.UITypeEditor)” to change the file browser attribute in property grid. please refer to the below code example. 
 
Code example: 
 
[VB] 
 
<EditorAttribute(GetType(System.Windows.Forms.Design.FileNameEditor), GetType(System.Drawing.Design.UITypeEditor))> _ 
 
 
Also, we have modified the sample to achieve your requirement. Please refer to the below attached sample and let us know if your requirement is achieves or not? 
 
Sample: 
 
 
Video: 
 
 
Regards, 
 
Naganathan K G 



AL Allen February 6, 2018 04:45 PM UTC

Thank you so much, Naganathan !
You have been a great help


NG Naganathan Ganesh Babu Syncfusion Team February 7, 2018 05:56 AM UTC

Hi Allen, 
Thanks for your update.  
We are happy to hear that your problem is resolved. Please let us know if you need any further assistance. 
Regards,  
Naganathan K G  
 



AL Allen February 7, 2018 06:17 AM UTC

Dear Naganathan,
Thank you so much!
As a final touch, if I may ask, is it possible to access Price value from a button_click like the following:

Button_Click (....)
 Dim P as String
 P = SelectedNode.Price
End


NG Naganathan Ganesh Babu Syncfusion Team February 8, 2018 06:39 AM UTC

Hi Allen, 
 
Yes, we can access the selected node’s price property in button click. Please refer to the below code example and modified sample.  
 
Code example: 
 
[VB] 
 
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
            If diagram1.View.SelectionList.Count = 1 AndAlso (TypeOf diagram1.View.SelectionList(0) Is CustomBitmapNode) Then 
                Dim SelectedNode As CustomBitmapNode = TryCast(diagram1.View.SelectionList(0), CustomBitmapNode) 
                Dim p As String = SelectedNode.Price 
            End If 
        End Sub 
 
Sample: 
 
 
Regards, 
 
Naganathan K G 



AL Allen February 8, 2018 06:51 AM UTC

Perfect, thank you so much, Naganathan


NG Naganathan Ganesh Babu Syncfusion Team February 9, 2018 04:08 AM UTC

Hi Allen, 
 
Thanks for your update.  
 
We are happy to hear that your problem is resolved. Please let us know if you need any further assistance. 
 
Regards,  
 
Naganathan K G  


Loader.
Up arrow icon