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
555
Numeric fields aligment
posted

Hi,

We have the requiriment that while the text and dates are alinged to the left, numeric fields (decimal, int...) should be aligned to the right. There is any way to do it using styles? or any small code change.

Thanks

Parents
  • 71886
    Verified Answer
    Offline posted

    Hello jcmarq,

    You could use the following code in order to achieve this:

            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                foreach (UltraGridColumn col in e.Layout.Bands[0].Columns)
                {
                    if (col.DataType == typeof(string) || col.DataType == typeof(DateTime))
                        col.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Left;
                    else if (col.DataType == typeof(int) || col.DataType == typeof(double) || col.DataType == typeof(Decimal))
                        col.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
                }
            }
    

     

    Please feel free to let me know if I misunderstood you or if you have any other questions.

Reply Children