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

How to retain Selected Value based on user input

7 Answers 101 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Dharmavaram
Top achievements
Rank 1
Dharmavaram asked on 23 Sep 2016, 10:48 AM

 Hi,

   I have three choices for one of the property and I am showing them in combobox.Once user changes the choices we will take confirmation from user if he says no I have to retain the old value and show in the combo the selected value as oldvalue.But here I am not changing the value of model property but combobox value changing to new value.How to stop it??

 

For Example:

  Property Name :Transportation

Property Values : Enum vehicles

                             {

Bus,

Car,

Walk

                              }

 

 

7 Answers, 1 is accepted

Sort by
0
Dharmavaram
Top achievements
Rank 1
answered on 23 Sep 2016, 10:51 AM

Hi,

  In the above post I have given half information. If Selected value is Bus and then user changes to car.We will ask confirmation and If he says no I should not select car.But here in propertygrid it is showing Car. 

How to stop this??

Regards,

Nagasree.

0
Stefan
Telerik team
answered on 27 Sep 2016, 03:04 PM
Hello Nagasree,

Basically, you should be able to revert to the previous selected item through the Selection mechanism of the control. May I ask you to share a little more information on how the combobox editor is defined?

Best Regards,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dharmavaram
Top achievements
Rank 1
answered on 28 Sep 2016, 04:33 AM

Hi Stefan,

    I didn't specified Combobox Editor,PropertyGrid itself giving the Combobox Editor as the property type is Enum. As we know based on the type of the property propertygrid itself provides respective template for the PropertyValue,here I am gettting the Combobox.

Regards,

Nagasree

0
Stefan
Telerik team
answered on 29 Sep 2016, 12:07 PM
Hi Nagasree,

RadPropertyGrid does not expose its autogenerated editors for such modifications. A possible approach would be to define the EditorTemplate for the particular PropertyDefinition and setup the combobox within it. Please take a look at the Customized Property Definitions topic for more information on the matter.

Hopefully, this helps.

Regards,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dharmavaram
Top achievements
Rank 1
answered on 04 Oct 2016, 04:10 AM

Hi Stefan,

I have checked ComboboxEditorBooleanProperty_WPF  sample application. I already tried to create usercontrol and use it.But I am not able to achieve my expected behavior.

http://www.telerik.com/forums/how-to-show-list-string-as-combobox-values-instead-of-collection-editor

I have explained my problem in the above post still clearly. I completely blocked by this problem.Could you please help me??

0
Dharmavaram
Top achievements
Rank 1
answered on 04 Oct 2016, 12:32 PM

Hi Stefan,

  I am providing some more information here. Last one week I am doing lot of trial and errors.I will share that information with so that you can help me further.

<UserControl x:Class="DataGrid.CustomCombo"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d" d:DesignWidth="289" Height="69"  >
    <StackPanel>
        <telerik:RadComboBox Name="ControlCombo" SelectedIndex="{Binding SelectedValue, Mode=TwoWay}"/>
    </StackPanel>
 
</UserControl>

Property for which I am using above mentioned usercontrol as Editor. 

private String _stringProperty ="Hi";
 
     [Telerik.Windows.Controls.Data.PropertyGrid.Editor(typeof(CustomCombo),"SelectedValue", Telerik.Windows.Controls.Data.PropertyGrid.EditorStyle.None)]    
     public String StringProperty
     {
         get
         {
             return _stringProperty;
        
         }
 
         set
         {
             _stringProperty = value;
         }
        
     }
 
     private List<String> myVar = new List<string>() {"Nagasree","Sumasree","Sreeram"};
 
     public List<String> MyProperty
     {
         get { return myVar; }
         set { myVar = value; }
     }

I am populating the combobox from code behind in fieldloaded event as I didn't find any nice other approach as shown below.

private void PropertyGrid_FieldLoaded(object sender, FieldEventArgs e)
    {
        if (e.Field.Content is CustomCombo)
        {
            CustomCombo cb = e.Field.Content as CustomCombo;
            cb.ControlCombo.ItemsSource = ((Employee)cb.DataContext).MyProperty;
        }
 }

 

 Now I want to bind the selected Item in the combobox to the string Property.How to achieve this??

I tried to bind to the property in usercontrol creating DependencyProperty but I am not succesful.Please give solution as soon as possible.

Regards,

Nagasree.

0
Dharmavaram
Top achievements
Rank 1
answered on 05 Oct 2016, 09:36 AM

Hi,

I found answer here http://www.telerik.com/forums/how-to-show-list-string-as-combobox-values-instead-of-collection-editor#JX8h-tbgvkS_iBnINcu9iQ

Tags
PropertyGrid
Asked by
Dharmavaram
Top achievements
Rank 1
Answers by
Dharmavaram
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or