Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3305
How do you set a data format for a column in Code behind
posted

the C# code behind examples have all but disappeared with teeh advent of Xaml and it's extremely frustrating that I have to come onto a forum to  figure out how to implement something that should take 30 seconds to do and is not documented in any help file.

can someone please post some C# code not xaml. that shows how do to this?

Parents
No Data
Reply
  • 9836
    posted

    Hi ,

    I suppose you want to set XamTextEditor.Format property from the codebehind. In this case you can try

    the following :

    private void xamDataGrid1_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)
    {
                Style stl = new Style();
                Setter set=new Setter();
                set.Property=XamTextEditor.FormatProperty;
                set.Value="N8";
                stl.TargetType = typeof(XamTextEditor);
                stl.Setters.Add(set);


                xamDataGrid1.FieldLayouts[0].Fields[1].Settings.EditAsType = typeof(Double);
                xamDataGrid1.FieldLayouts[0].Fields[1].Settings.EditorType = typeof(XamTextEditor);
                xamDataGrid1.FieldLayouts[0].Fields[1].Settings.EditorStyle = stl;
    }

    I'm using a XamTextEditor to Format a double value.

    Hope this helps

    Vlad

Children