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
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.
Is it possible to achieve the same effect using Format/Masks? In our grid we change appareance of cells dinamically and doing it this way we could end having too many "Appareance" objects right?