Hi Team,
I'm using DataSource to bind a class to the UltraGrid.
I have an object inside which there're nested lists of strings, like below, I want to show the deepest level as columns instead of rows. Is there a way I can achieve this?
I want the GUI looks like "FlatInnerObject", but I want to use list of string in code(like class "InnerObject") rather than list out all string properties(like class "FlatInnerObject"), as the length of attribute list could be changing. i.e., if there're 10 columns in FlatInnerObject, I don't want to list 10 string properties there...
private IBindingList _rows = new BindingList<OutterObject>(); public Form1() { InitializeComponent();
ultraGrid1.DataSource = _rows;
var outterObject = new OutterObject { Summary = "Testing Summary" }; var innerObject = new InnerObject(); innerObject.AddAttribute("column1"); innerObject.AddAttribute("column2");
outterObject.AddInnerObject(innerObject); outterObject.AddInnerObject(innerObject);
var flatInnerObject = new FlatInnerObject() { Column1 = "flat column 1", Column2 = "flat column 2", }; outterObject.AddFlatInnerObject(flatInnerObject); outterObject.AddFlatInnerObject(flatInnerObject);
_rows.Add(outterObject);
SetUpGridColumns();
}
public class OutterObject
{ private readonly BindingList<InnerObject> _innerObjects = new BindingList<InnerObject>(); private readonly BindingList<FlatInnerObject> _flatInnerObjects = new BindingList<FlatInnerObject>();
public string Summary { get; set; }
public BindingList<InnerObject> InnerObjects { get { return _innerObjects; } }
public void AddInnerObject(InnerObject o) { _innerObjects.Add(o); }
public BindingList<FlatInnerObject> FlatInnerObjects { get { return _flatInnerObjects; } }
public void AddFlatInnerObject(FlatInnerObject o) { _flatInnerObjects.Add(o); } }
public class InnerObject { private readonly BindingList<string> _attributes = new BindingList<string>();
public BindingList<string> Attributes { get { return _attributes; } }
public void AddAttribute(string a) { _attributes.Add(a); } }
public class FlatInnerObject { public string Column1 { get; set; } public string Column2 { get; set; } }
Hi Shirley,
Thank you for pointing it out! The link has been changed to the correct one.
Please try to follow my approach and if you get any difficulties don’t hesitate to look for my assistance.
Hi Ivaylo,
Thanks for the prompt reply. Just wonder is your link correct? It's about ViewStyleBand, not about unbound column.
Regards,
Shirley
Thank you for posting in our forum!
As I understand you want to swap inner object’s cells to columns for the deepest band of your hierarchical grid.
The first solution that I suggest you is to hide inner object’s initial columns and create unbound columns based on the number of inner object’s initial number of rows/cells along with optionally restricting that number as per your requirement.
Here you can read how to add unbound column to UltraGrid: http://help.infragistics.com/Help/Doc/WinForms/2012.2/CLR4.0/html/WinGrid_Add_Unbound_Columns_to_WinGrid.html
Let me know if you have additional questions about this scenario and its implementation.