Saving DropDownList change

8 posts, 1 answers
  1. Marcin Żak
    Marcin Żak avatar
    3 posts
    Member since:
    Jun 2012

    Posted 28 Jun 2012 Link to this post

    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
  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 03 Jul 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marcin Żak
    Marcin Żak avatar
    3 posts
    Member since:
    Jun 2012

    Posted 05 Jul 2012 Link to this post

    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.
  5. Tom Mieck
    Tom Mieck avatar
    11 posts
    Member since:
    Aug 2012

    Posted 29 Jul 2012 Link to this post

    Hi,
    Can u pls send me a code how to put dropdowneditor in propertygrid in winforms 

    Pls help me
  6. Marcin Żak
    Marcin Żak avatar
    3 posts
    Member since:
    Jun 2012

    Posted 31 Jul 2012 Link to this post

    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;
     }
       }
  7. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 02 Aug 2012 Link to this post

    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 >>
  8. Tom Mieck
    Tom Mieck avatar
    11 posts
    Member since:
    Aug 2012

    Posted 16 Aug 2012 Link to this post

    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
  9. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 20 Aug 2012 Link to this post

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready