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

Saving DropDownList change

7 Answers 240 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Marcin Żak
Top achievements
Rank 1
Marcin Żak asked on 28 Jun 2012, 10:25 AM
Hi,
I have many PropertyGridDropDownListEditor elements on my RadPropertyGrid. Every list is loaded at startup and positioned on proper value. After changing value, I need to click anywhere on my RadPropertyGrid to save changed row data (showing black square with small red triangle which allow to undo changes etc.). If I don't do it - data is lost. I mean, when I'm changing value at DropDownList and immediately click myForm save button. I want to save this data too, but I don't know how. I'm using C#.


Greetings,
Marcin

7 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 03 Jul 2012, 08:26 AM
Hi Marcin,

Thank you for writing.

I tried to reproduce your scenario but everything worked as expected on my side. What you can do is to call the EndEdit method of RadPropertyGrid before you execute any other logic in your Save button. This would force the property grid into closing the active editor and saving the value.
I would kindly ask you to send me your project or a sample one where you reproduce the issue so I can investigate it and provide you with more precise information.

Looking forward to your reply.
 
Greetings,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Marcin Żak
Top achievements
Rank 1
answered on 05 Jul 2012, 03:49 PM
Thank for your reply Ivan,

Shame on me, because EndEdit method was the solution that I've looked for. I don't know why, but I just missed this method.

Sorry for wasting your time on something like that ;)
Anyway, many thanks,
Marcin.
0
Tom Mieck
Top achievements
Rank 1
answered on 29 Jul 2012, 06:30 AM
Hi,
Can u pls send me a code how to put dropdowneditor in propertygrid in winforms 

Pls help me
0
Marcin Żak
Top achievements
Rank 1
answered on 31 Jul 2012, 09:31 AM
My code:

private RadPropertyStore CreateRadPropertyStore()
{
            RadPropertyStore store = new RadPropertyStore();
            PropertyStoreItem psItem;
 
            psItem = new PropertyStoreItem(typeof(string), "Name", default_value, "Name details", "Category");
            psItem.Value = item_value;
            store.Add(psItem);
   }

        private void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
        {               
                PropertyGridDropDownListEditor editor = e.Editor as PropertyGridDropDownListEditor;
                BaseDropDownListEditorElement editorElement = editor.EditorElement as BaseDropDownListEditorElement;
                editorElement.ValueMember = "Id"; //column in dataSet1
                editorElement.DisplayMember = "Value"//column in dataSet1 
                switch (e.Item.Name)
                {
                    case "Name":
                        dataViev1.Table = dataSet1.Tables[0];
                        editorElement.DataSource = dataViev1;
                        break;
          }
   }

        private void radPropertyGrid1_EditorRequired(object sender, PropertyGridEditorRequiredEventArgs e)
        {
            switch (e.Item.Name)
            {               
                case "OtherTextBoxField":
                    e.EditorType = typeof(PropertyGridTextBoxEditor);
                    break;                  
      default:
                    e.EditorType = typeof(PropertyGridDropDownListEditor);
                    break;
 }
   }
0
Ivan Petrov
Telerik team
answered on 02 Aug 2012, 06:12 AM
Hi guys,

Thank you both for writing.

@Marcin: Thank you for sharing your solution with the community. I have updated your Telerik points for your time and effort.

@Tom Mieck: Marcin's approach is the right way to go in this case. If you encounter any difficulties, do not hesitate to write back.
 
All the best,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Tom Mieck
Top achievements
Rank 1
answered on 16 Aug 2012, 06:35 PM
Hi,
What exactly is the difference between the radPropertyGrid1_EditorInitialized  and radPropertyGrid1_EditorRequired 
methods.
I have written some code to display one textbox and checkbox in one property in the radPropertyGrid1_EditorInitialized 
But when i click on any property it is showing the  one textbox and checkbox in all the properties in the propertygrid, dont no y???
how ever it was working fine in the radPropertyGrid1_EditorRequired  method
0
Ivan Petrov
Telerik team
answered on 20 Aug 2012, 01:27 PM
Hi Tom Mieck,

Thank you for writing back.

The EditorRequired event is fired before the editor which will be used for editing the property is inserted in the editing mechanism of RadPropertyGrid. This is the event where you can change the editor that would be used for a given property. The EditorInitialized event is fired after the editor is instantiated and is used for fine tuning the settings of this editor.

I hope this will be informative. If you have further questions, I would be happy to help. 

All the best,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
PropertyGrid
Asked by
Marcin Żak
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Marcin Żak
Top achievements
Rank 1
Tom Mieck
Top achievements
Rank 1
Share this question
or