locked
Can't edit properties I added in a Control derived class

    Question

  • Hi all;

    I have a class derived from XtraUserControl (DevExpress' UserControl derived class). I have 2 properties in it with public get; protected set;

    The two properties display in the property list. I can type strings in for them. But when I click out of that box, the string goes away and it is not set in the file.designer.cs file. And if I type something in the file.designer.cs file directly, it is not displayed in the property.

    What else do I have to do?

    thanks - dave


    Who will win The International Collegiate Programming Championships?

    Friday, March 09, 2012 6:47 PM

Answers

  • Hi David,

    Based on your new project, I think I have understood your issue well.

    I reproduce your issue by the following steps:

    1. Rebuild the project.

    2. Drag a xtraUserControl1 control on the form1. (In designer view)

    3. Go to the properties view of this control, and I saw PageTitle and PageSubtitle properties.

    4. I input a string in both textbox, and as you said, the string disappeared.

    Based on my understanding, this is because the set method is "protected" that the form1 class cannot access it: http://msdn.microsoft.com/en-us/library/bcd5672a(v=vs.110).aspx 

    The protected keyword is a member access modifier. A protected member is accessible within its class and by derived class instances. For a comparison of protected with the other access modifiers, see Accessibility Levels

    I hope this is clear.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by DavidThi808 Thursday, March 15, 2012 3:25 PM
    Thursday, March 15, 2012 4:35 AM
  • Hi Dave,

    When you need to assign a value to a property, you need to call its set method, only the set method can accept a value. I can say I saw some properties are read-only, why they are read-only? Because it doesn't have set method, it only can provide a value by the get method. When the Form1 class cannot access the set method, as I have said, it cannot call the set method to assign a value to that property.

    I hope I am clear.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 16, 2012 2:44 AM

All replies

  • Hi Dave,

    Welcome to the MSDN Forum.

    Do you set the property of your control? Or a property of your class and this property is reflected to the user controls property?  

    Would you like to share your related code here? It will be better to me to reproduce your scenario.

    I look forward you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, March 11, 2012 8:42 AM
  • Hi Mike;

    Thanks for your reply. Please open http://www.windward.net/temp/propprob.zip in VisualStudio 2010 and then try to set the properties XtraUserControl1.PageSubtitle and PageTitle. You can type in their fields in the properties window but when you move to another window what you typed goes away.

    ??? - thanks - dave


    Who will win The International Collegiate Programming Championships?

    Monday, March 12, 2012 10:45 PM
  • Hi David,

    I have download your project,

    Actually, I cannot compile it because there is no DevExpress.XtraEditors namespace.

    In addition, I didn't see a user control in form1, so would you like to post the details steps how can I reproduce this issue?

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 14, 2012 3:22 AM
  • Hi Mike;

    I uploaded one without DevExpress at www.windward.net/temp/propprob2.zip

    The sample properties are in the XtraUserControl1 class - PageSubtitle and PageTitle.

    thanks - dave


    Who will win The International Collegiate Programming Championships?

    Wednesday, March 14, 2012 7:48 PM
  • Hi David,

    Based on your new project, I think I have understood your issue well.

    I reproduce your issue by the following steps:

    1. Rebuild the project.

    2. Drag a xtraUserControl1 control on the form1. (In designer view)

    3. Go to the properties view of this control, and I saw PageTitle and PageSubtitle properties.

    4. I input a string in both textbox, and as you said, the string disappeared.

    Based on my understanding, this is because the set method is "protected" that the form1 class cannot access it: http://msdn.microsoft.com/en-us/library/bcd5672a(v=vs.110).aspx 

    The protected keyword is a member access modifier. A protected member is accessible within its class and by derived class instances. For a comparison of protected with the other access modifiers, see Accessibility Levels

    I hope this is clear.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by DavidThi808 Thursday, March 15, 2012 3:25 PM
    Thursday, March 15, 2012 4:35 AM
  • Hi Mike;

    Making it public fixes it. But why is that required? Setting it in the properties window will then set it in the code for that class - that should work even if it's private.

    ??? - thanks - dave


    Who will win The International Collegiate Programming Championships?

    Thursday, March 15, 2012 3:26 PM
  • Hi Dave,

    When you need to assign a value to a property, you need to call its set method, only the set method can accept a value. I can say I saw some properties are read-only, why they are read-only? Because it doesn't have set method, it only can provide a value by the get method. When the Form1 class cannot access the set method, as I have said, it cannot call the set method to assign a value to that property.

    I hope I am clear.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 16, 2012 2:44 AM