Grid formatting and Alignment

In the image below I have 3 numeric values, Pack Qty, Order, and Order Qty.

I want them all to look the same, that is No Decimals, Right Aligned, I could take or leave the Comma in the Order Qty.

I have changed Extended Properties, Grid Properties, Mask Input. I have made them all the same in every way that I can see, yet they display differently.

OrderDtl.OrderNum is an Integer with No business type, Default format of >>>>>>>9, it has no Extended Properties Changes - I like the way it looks and the fact that it aligns right.

OrderDtl.OrderQty is a Decimal, with a default format of >>>,>>>,>>>,>>9.99 but an Extended Properties format of >>>>>9. I blanked out the Business Type, which used to read ‘Quantity’, I want it to hide the decimals and ideally to keep the comma .

OrderDtl_UD.Number05 (Pack Qty) is a decimal with a default format of ->>>,>>>,>>9.99999 but an Extended Properties format of >>>>>>9, and wants to Left-Align in the grid cell, I want it to Align Right

I have tried ########0 for format and nnnnnnnnn for MaskInput in the Column Properties of the grid with no luck.

image

It’s a giant pain in the rear, but you could programtically set the mask on these columns by adding an InitializeLayout event on that grid and then setting the Format property of the column by index

private void grdTendon_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs args)
	{
		// ** Place Event Handling Code Here **
			args.Layout.Bands[0].Columns[3].Format = "###,###,##0.0";
			args.Layout.Bands[0].Columns[4].Format = "###,###,##0.0";
			args.Layout.Bands[0].Columns[5].Format = "###,###,##0.0";
			args.Layout.Bands[0].Columns[6].Format = "###,###,##0.0";
			args.Layout.Bands[0].Columns[7].Format = "###,###,##0.0";
			args.Layout.Bands[0].Columns[8].Format = "###,###,##0";
			//grdTendon.DisplayLayout.Bands[0].Columns[3].Header.Caption = "Length";
			//grdTendon.DisplayLayout.Bands[0].Columns[4].Header.Caption = "Fdd diameter";
			//grdTendon.DisplayLayout.Bands[0].Columns[5].Header.Caption = "Single Diameter";
			//grdTendon.DisplayLayout.Bands[0].Columns[6].Header.Caption = "Fdd Diameter 2";
			//grdTendon.DisplayLayout.Bands[0].Columns[7].Header.Caption = "Width";
		    //grdTendon.DisplayLayout.Bands[0].Columns[8].Header.Caption = "Age";
	}
2 Likes

Thanks Aaron! I will update ASAP if I can adapt this example to my challenge, it looks like you are spot on.

1 Like

Yeah, sometimes it’s those simple things…