Ticket Q344173
Visible to All Users

changing caption at run time

created 13 years ago

Hello Sir,
In my application i have two currencies First Base Currency and Second Base Currency.
In my invoice I have a field called "RateToFB" Rate to first base currency.
I have a problem; every time i change the first base currency i rename this field to the changed currency.
Example if First base currency is USD i rename this field to "RateTo USD"
             if First base currency is EURO i rename this field to "RateTo EURO".
For this purpose i want to change this caption at run time

1- before loading the view (list/DetailView) read what is First base currency
2- Change its value.
I created a controller to do this but still facing some problems

the code below is for the view controller:
    protected override void OnActivated()
        {
   if (View is DetailView)
            ((DevExpress.ExpressApp.Win.Layout.WinLayoutManager)((View as DetailView).LayoutManager)).ItemCreated += ItemCreated;
}
   void ItemCreated(object sender, DevExpress.ExpressApp.Win.Layout.ItemCreatedEventArgs e)
        {
 if(fb==null)
            fb=View.ObjectSpace.GetFirstBaseCurrency();

if(sb==null)
            sb=View.ObjectSpace.GetSecondBaseCurrency();
    if (typeof(Invoice).IsAssignableFrom(View.ObjectTypeInfo.Type))
            {
                if (e.ViewItem != null && e.ViewItem is DevExpress.ExpressApp.Win.Editors.LookupPropertyEditor)
                {
                    DevExpress.ExpressApp.Win.Editors.LookupPropertyEditor editor = (DevExpress.ExpressApp.Win.Editors.LookupPropertyEditor)e.ViewItem;

if (fb!=null && editor.PropertyName.Contains("RateToFB") && editor.Caption!=fb.ISOCurrencySymbol)
                    {

(sender as DevExpress.ExpressApp.Win.Layout.WinLayoutManager).EnableCaptionColon=false;
                     editor.Caption = fb.ISOCurrencySymbol;
                   (sender as DevExpress.ExpressApp.Win.Layout.WinLayoutManager).Container.Refresh();
                    }

if (sb!=null && editor.PropertyName.Contains("RateToSB")&& editor.Caption!=sb.ISOCurrencySymbol)
                    {

(sender as DevExpress.ExpressApp.Win.Layout.WinLayoutManager).EnableCaptionColon=false;
                        editor.Caption = sb.ISOCurrencySymbol;
                        (sender as DevExpress.ExpressApp.Win.Layout.WinLayoutManager).Container.Refresh();
                    }
                }
            }
        }
please help me to solve the following problems:
 1-not available for list view
 2-I still need to open the detail view twice to apply the new value using this controller.
Thank you,
Ali

Comments (1)
Dennis Garavsky (DevExpress) 13 years ago

    Hi Ali,
    Thank you for contacting us. I fully understand your task and need some time to fix your controller.
    It does not work for ListViews because it is not supposed to do so as WinLayoutManager.ItemCreated is primarily fused or DetailView. In case of ListView you will have to access GridControl columns and change their caption.
    Refer to the Access Editor Settings help article for more information.
    Thanks,
    Dennis
    P.S.
    Our record shows that your Master account has no personal developer license assigned for the Contact account you currently use with our Support Cervices. Please ask your manager to assign a license for you. This can be accomplished through the “Purchase | Manage & Assign Licenses” menu of our web site (authorization required).

    Answers

    created 13 years ago

    Hi Ali,
    Here is a modified version of your controller that works fine in DetailViews:

    C#
    using DevExpress.ExpressApp; using DevExpress.ExpressApp.Win.Layout; namespace MainDemo.Module.Win { public partial class Q344173 : ViewController<DetailView> { public Q344173() { TargetObjectType = typeof(Contact); } protected override void OnActivated() { ((WinLayoutManager)View.LayoutManager).ItemCreated += ItemCreated; } protected override void OnDeactivated() { ((WinLayoutManager)View.LayoutManager).ItemCreated -= ItemCreated; base.OnDeactivated(); } void ItemCreated(object sender, DevExpress.ExpressApp.Win.Layout.ItemCreatedEventArgs e) { if (e.ViewItem != null && e.ViewItem.Id == "FirstName" && e.Item != null) e.Item.Text = "123"; } } }

    Please let me know if I can assist you further.
    Thanks,
    Dennis

      Comments (1)
      Dennis Garavsky (DevExpress) 13 years ago

        Great news!
        Regards,
        Dennis

        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.