I've created a custom cell in a GridView with two labels. It works so long as the grid isn't resized or the number of rows do not exceed the length of the grid. When either of the two occur the custom cells can loose their formatting and cells without formatting adopt traits from the custom formatting.
This snippet demonstrates the issue.
A bump in the right direction would be appreciated.
using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using Telerik.WinControls.Layouts;using Telerik.WinControls.UI;namespace TR_Test{ public partial class GridTest : Telerik.WinControls.UI.RadForm { public GridTest() { InitializeComponent(); //simple grid this.radGridView1.CreateCell += new Telerik.WinControls.UI.GridViewCreateCellEventHandler(this.radGridView1_CreateCell); this.radGridView1.AllowAddNewRow = false; this.radGridView1.AllowSearchRow = false; this.radGridView1.ShowGroupPanel = false; this.radGridView1.ShowRowHeaderColumn = false; this.radGridView1.TableElement.RowHeight = 60; // Populate the grid with data PopulateGrid(); radGridView1.Columns["Info"].Width = 150; } private void PopulateGrid() { List<Sales> myList = new List<Sales>(); myList.Add(new Sales(1, "Outdoor,1111", "asdf", "asdf")); myList.Add(new Sales(2, "Hardware,2222", "asdf", "asdf")); myList.Add(new Sales(3, "Tools,3333", "asdf", "asdf")); myList.Add(new Sales(4, "Books,4444", "asdf", "asdf")); myList.Add(new Sales(5, "Shows,5555", "asdf", "asdf")); myList.Add(new Sales(6, "Mugs,6666", "asdf", "asdf")); myList.Add(new Sales(7, "Phones,7777", "asdf", "asdf")); myList.Add(new Sales(8, "Indore,8888", "asdf", "asdf")); myList.Add(new Sales(9, "Cats,9999", "asdf", "asdf")); myList.Add(new Sales(10, "Dogs,0000", "asdf", "asdf")); myList.Add(new Sales(11, "Outdoor,1111", "asdf", "asdf")); myList.Add(new Sales(12, "Hardware,2222", "asdf", "asdf")); myList.Add(new Sales(13, "Tools,3333", "asdf", "asdf")); myList.Add(new Sales(14, "Books,4444", "asdf", "asdf")); myList.Add(new Sales(15, "Shows,5555", "asdf", "asdf")); myList.Add(new Sales(16, "Mugs,6666", "asdf", "asdf")); myList.Add(new Sales(17, "Phones,7777", "asdf", "asdf")); myList.Add(new Sales(18, "Indore,8888", "asdf", "asdf")); myList.Add(new Sales(19, "Cats,9999", "asdf", "asdf")); myList.Add(new Sales(20, "Dogs,0000", "asdf", "asdf")); radGridView1.BindingContext = new BindingContext(); radGridView1.DataSource = myList; } private void radGridView1_CreateCell(object sender, Telerik.WinControls.UI.GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridDataCellElement)) { GridViewDataColumn dataColumn = e.Column as GridViewDataColumn; switch (dataColumn.Name) { case "Info": e.CellType = typeof(SplitCell); break; } } } } public class SplitCell : GridDataCellElement { private StackLayoutPanel panel; private RadLabelElement label1; private RadLabelElement label2; public SplitCell(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override void CreateChildElements() { base.CreateChildElements(); this.panel = new StackLayoutPanel { Margin = new System.Windows.Forms.Padding(5), Orientation = System.Windows.Forms.Orientation.Vertical }; this.label1 = new RadLabelElement { Font = new Font("Segoe UI", 16.0f) }; this.panel.Children.Add(this.label1); this.label2 = new RadLabelElement { Font = new Font("Segoe UI", 9.0f) }; this.panel.Children.Add(this.label2); this.Children.Add(this.panel); } protected override void SetContentCore(object value) { object cellValue = value; this.label1.Text = ""; this.label2.Text = ""; if (cellValue is DBNull || cellValue == null) cellValue = ","; string[] s = cellValue.ToString().Split(','); if (s.Length >= 1) this.label1.Text = s[0]; if (s.Length >= 2) this.label2.Text = s[1]; } } public class Sales { public Sales(int id, string info, string PO, string Paid) { this.ID = id; this.Info = info; this.PO = PO; this.Paid = Paid; } public int ID { get; set; } public string Info { get; set; } public string PO { get; set; } public string Paid { get; set; } }}