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?
I think that this is not so much. If you think that setting the appearance will bring down your performance, please do some test with a performance profiler and let me know of the results if they are not satisfying.
We have some grids with just 2/3 columns but also other grids having 30-40 columns and hundreds of rows. I thought there could be any way to do it using Masks to arrage the digits to the right.
I do not know how this could be achieved by using Format or MaskInput. These properties are used to 'arrange' the text/value in the column, like which digits, characters where and how to be shown in the value of the cells. These are not used to change the appearance of the cells in any way.
Also, how many columns do you expect to have? I am not sure that these appearances could affect your performance and in the same time to have practical WinGrid layout, user-friendly.
Please do not hesitate to contact me if you need any additional assistance.