locked
Data driven labels RRS feed

  • Question

  • Is it possible to have labels that are data driven? For example, and app has 5 organization levels. We allow the user to specify the names of each organization level. I want to display there description rather than "Level1" next to the values on the edit forms and grid. 

    Is this possible?

    BOb

     

     

     

    Friday, April 15, 2011 8:40 PM

Answers

  • The built-in LightSwitch controls does not allow you to bind the label to a value.  But you can change the label by writing some custom code.

     

           partial void MyScreen_Created()
    
            {
    
                this.FindControl("Property1").DisplayName = "My Level";
    
            }
    
    


    LLF
    Friday, April 15, 2011 9:11 PM

All replies

  • The built-in LightSwitch controls does not allow you to bind the label to a value.  But you can change the label by writing some custom code.

     

           partial void MyScreen_Created()
    
            {
    
                this.FindControl("Property1").DisplayName = "My Level";
    
            }
    
    


    LLF
    Friday, April 15, 2011 9:11 PM
  • What if I want to change the header text for the DataGrid columns? Like for the Data Grid in a Search Data Screen?

    The grid is shown shaded before the Created event is called. This shaded preview shows the invalid header text (i.e. "Column 1") that needs to be changed.

    I see that InitializeDataWorkspace is called before the shaded preview is shown. Can I code in that event?

    I have a field properties table that contains a record for each column with the user defined text for the header. I want to bind each grid column's header text to the matching record in that table. Since it seems that I cannot bind them, I need to know the code to use to set the text for each column header before the grid is displayed (even shaded).

    For example, I have a Data Grid Control Named "My_Records" and a column name in the Data Grid Row is "Column_1".

    FindControlInCollection seems to only be for finding each individual row control. Setting the DisplayName for one of them does not seem to set header text. What code will change the header text?

    I would use an event and FindControl("Records")'s ControlAvailable event, then e.Control as DataGrid... but, the grid.Columns Header objects are internal LightSwitch wrapper types (setting Column.Header = "My Label" leaves the header blank).

    In any case, I would need to make the changes before the shaded preview is shown or I would need to suppress the shaded preview.

    Thanks.

     

     

     

     

    Thursday, April 21, 2011 8:31 PM