CodeSmith Community
Your Code. Your Way. Faster!

Another trick to help with Winform edit controls

Latest post 11-26-2007 9:38 AM by swin. 3 replies.
  • 07-25-2007 8:48 PM

    • JRich
    • Top 150 Contributor
    • Joined on 04-24-2007
    • Posts 30
    • Points 785

    Another trick to help with Winform edit controls

    The basic NetTiers script used to produce the Window.Forms Edit Control library (TableEditControlBase.cst) creates the edit control labels using the entity (table) field names. So if you want to utilize these user controls, you have to change the labels each time you recreate your NetTiers project. Very annoying!
     
    But I found a work around.
     
    In SQL Server you can set the extended properties of any object. For example, the default extended property is "MS_Description". For each field in my database I set the MS_Description property to the display name I wanted to appear in that field's label. Then I modified the TableEditControlBase script to use this property value as my label.text contents rather than the field names.
     
    So here is how you can do it.
     
    1. Open your SQL Server tables and use the extended property "MS_Description" to hold the strings you want to appear in the edit control labels.
    2. Open the TableEditControlBase.cst in NetTiers studio edit mode.
    3. Use the script in the attached file to replace the code between these two labels (to make things more clear, I left these labels in the attached script)
     
        //
       // uxErrorProvider
       //
    *****************************************************
     
    NEW STUFF HERE
     
    ******************************************
     //this.uxTableLayoutPanel.Controls.Add(this.<%=dgvColumnName%>Label);   
       //
     
    Now when you recreate your datalayer and include the Windows.Forms module, the custom controls will reference the strings you put into each field's MS_Description extended property.
     
    Very handy....
     
    Have fun
     
    Joe Rich
    Rich Solutions
    • Post Points: 55
  • 10-21-2007 10:53 AM In reply to

    • NoelRAM
    • Top 500 Contributor
    • Joined on 08-25-2005
    • Caracas
    • Posts 9
    • Points 165

    Re: Another trick to help with Winform edit controls

    In the october version this TableEditControlBase.cst template does not have this code. Will you indicate how to show the extended property in this new version? I will appreciate.

    Regards and thanks for your job

    Noel Enrique

    • Post Points: 35
  • 10-29-2007 11:43 AM In reply to

    • Polar
    • Top 100 Contributor
    • Joined on 09-04-2007
    • Posts 49
    • Points 895

    Re: Another trick to help with Winform edit controls

    I'm also looking for how to do this. 

    • Post Points: 35
  • 11-26-2007 9:38 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Another trick to help with Winform edit controls

     This has been fixed in SVN676 to use the FriendlyName from the mapping.config file.

    hth

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems