Hello, I am new to the WinGrid and wish to do the following:
At run-time, I set my grids datasource to a collection of objects I have built up and I have code in the "IntiialiseLayout" event that hides columns as necessary, what I wish to do is the below, I want an extra header that summarizes groups of columns:-
Person Address
ForeName, Surname, Addr 1, Addr 2, Town, State
I hope this is a good example
many thanks
Hi,
The easiest way to do this is to use Groups. Assuming you only have one level of grouping (as opposed to nested groups) then what you do is add two groups to the Groups collection of the Band. Then you assign each column to a group.
Something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridGroup personGroup = band.Groups.Add("Person"); UltraGridGroup addressGroup = band.Groups.Add("Address"); personGroup.Columns.Add(band.Columns["ForeName"]); personGroup.Columns.Add(band.Columns["Surname"]); addressGroup.Columns.Add(band.Columns["Addr 1"]); addressGroup.Columns.Add(band.Columns["Addr 2"]); addressGroup.Columns.Add(band.Columns["Town"]); addressGroup.Columns.Add(band.Columns["State"]); }
Thanks Mike, that works a treat, now im just trying to figure out how to center justify the text, the following does not work:
band.Groups(
"Person").CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center
What text are you trying to center?