private void CreateLayoutItems(LayoutControl layout) { layout.BeginUpdate(); try { layout.Clear(); IList <DocumentItemBase> documentItems = GetSortedDocumentItems(); if (documentItems.Count != 0) { int itemsPerRow = DefaultItemsPerRow; ItemsPerRowAttribute attr = MemberInfo.FindAttribute <ItemsPerRowAttribute>(); if (attr != null) { itemsPerRow = attr.Value; } for (int rowNumber = 0; rowNumber < Math.Ceiling((decimal)documentItems.Count / (decimal)itemsPerRow); rowNumber++) { LayoutControlGroup row = layout.AddGroup(); row.Name = GetId("Row", rowNumber); row.DefaultLayoutType = DevExpress.XtraLayout.Utils.LayoutType.Horizontal; row.GroupBordersVisible = false; for (int cellNumber = 0; cellNumber < itemsPerRow; cellNumber++) { if (rowNumber * itemsPerRow + cellNumber < documentItems.Count) { DocumentItemBase item = documentItems[rowNumber * itemsPerRow + cellNumber]; LayoutControlItem cell = new LayoutControlItem(layout, CreateDocumentItemEditor(item)); cell.Name = GetId("Cell", item); cell.Text = item.Caption; if (application.Model.Options.LayoutManagerOptions.EnableCaptionColon) { cell.Text += ":"; } row.Add(cell); } else { row.Add(new EmptySpaceItem()); } } } } } finally { layout.EndUpdate(); layout.BestFit(); } }