Ticket Q519588
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

ConditionalAppearance - How do I customize the item caption text based on a certain condition

Set Class and Property DisplayName dinamically

created 12 years ago

Hi,

I would like to change the display (XafDisplayName attribute) name of one of my businessclass. It has a string property, and I also would like to change the display name for it.

This is the constructor of my class, where I'm trying to achieve it:

C#
public PopUpTextEdit(Session session, string formCaption, string textCaption) : base(session) { this.ClassInfo.AddAttribute(new XafDisplayNameAttribute(formCaption)); this.ClassInfo.GetMember("Text").AddAttribute(new XafDisplayNameAttribute(textCaption)); }

But this approach does not work. Can you tell me what do I do wrong? Or how can I change those properties dinamically. This class is btw a non-persistent class, but I don't think it makes any difference.

Thanks in advance!

Comments (1)

    Maybe I have to rephrase my question to the following: How to add/edit class or property attributes dynamically at the constructor of the business class (or at any of the init events)?

    Answers approved by DevExpress Support

    created 12 years ago (modified 11 years ago)

    Hello Balázs,
    You can add/remove attributes dynamically in the ModuleBase.CustomizeTypesInfo method. Feel free to contact us if you have any difficulty with this approach.

      Show previous comments (3)

        Hi Manuel,
        Thanks for the sample, I did not solve the way you did, but you gave me an idea how to achieve the behavior I wanted.

        Anatol (DevExpress) 12 years ago

          I am happy to hear that you have found a solution,
          From my side, I suggest you use another approach: handle the WindowTemplateController.CustomizeWindowCaption event, as shown in the How to: Customize a Window Caption article. Hope you find it helpful.

            Hi Anatol,
            Well my aim was not just to change the window caption, but also the label for a single text editor, so your approach does not really fit into it. Anyway thanks for the suggestion.
            My solution was to add 2 properties to the business class (Caption, TextLabel) and I set them thru the contructor of the class. I also created a viewcontroller targeted to this class's detailvew and in the OnActivated function I just simply replace these labels with the actual values. It works just fine, and it's quite simple.
            My problem was, that I tried to control the view from the model, which was wrong approach.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.