public virtual void UpdateListRowsData(List <List <object> > viewData) { var feedDataType = LiveFeedData.GetType(); var gridRows = pnlDetail.Controls .OfType <ListRow>() .Where(l => l.Index >= 0) .OrderBy(l => l.Index) .ToList(); if (gridRows.Count == 0) { return; } for (int i = 0; i < gridRows.Count(); i++) { ListRow row = gridRows.FirstOrDefault(r => r.Index == i); if (i < viewData.Count) { List <object> dataRow = viewData[i]; for (int x = 0; x < dataRow.Count; x++) { var label = row .Controls .OfType <Label>() .FirstOrDefault(r => ((ViewListColumn)r.Tag).Index == x); var column = ((ViewListColumn)label.Tag); if (!String.IsNullOrEmpty(column.Format)) { label.Text = FormatValue(dataRow[x], column.Format); } else { label.Text = dataRow[x].ToString(); } } } else { // More grid rows than data rows row.ClearColumns(); } } }
protected virtual void InitializeGridRows(ViewListSettings settings) { ClearGridControls(); if (settings.ShowColumnCaptions) { GridHeader = new ListHeader() { Height = settings.RowHeight.HasValue ? settings.RowHeight.Value : DefaultRowHeight }; } var gridRow = new ListRow() { Height = settings.RowHeight.HasValue ? settings.RowHeight.Value : DefaultRowHeight, Index = 0 }; ColumnBuilderService.BuildGridColumns(settings, GridHeader.Controls, gridRow.Controls); pnlDetail.Controls.Add(GridHeader); if (State.ListSettings.Columns.Count > 0) { gridRow.Controls.OfType <Label>().FirstOrDefault(c => ((ViewListColumn)c.Tag).Index == 0).Text = "0"; pnlDetail.Controls.Add(gridRow); var maxRows = settings.MaxRows.HasValue ? settings.MaxRows.Value : 8; for (int i = 1; i < maxRows; i++) { var newRow = gridRow.DeepCopy(); newRow.Index = i; newRow.Controls.OfType <Label>().FirstOrDefault(c => ((ViewListColumn)c.Tag).Index == 0).Text = i.ToString(); pnlDetail.Controls.Add(newRow); newRow.BringToFront(); } } GridHeader.SendToBack(); }
public virtual ListRow DeepCopy() { ListRow newRow = new ListRow() { BackColor = this.BackColor, ForeColor = this.ForeColor, Font = this.Font, BorderStyle = this.BorderStyle, Dock = this.Dock, Width = this.Width, Height = this.Height, Tag = this.Tag, }; foreach (Label label in this.Controls.OfType <Label>()) { Label newLabel = new Label() { Text = label.Text, TextAlign = label.TextAlign, AutoSize = label.AutoSize, Dock = label.Dock, BackColor = label.BackColor, ForeColor = label.ForeColor, Font = label.Font, BorderStyle = label.BorderStyle, Width = label.Width, Height = label.Height, Tag = label.Tag, }; newRow.Controls.Add(newLabel); } return(newRow); }