Hi all, I'm wondering if someone can tell me how to dynamically associate a field in an UltraGrid with a group defined in the UltraGrid?
I am using Progress OpenEdge 11.2 with the 11.2.20112.2124 version of the control, and I can add the group and fields to the group at design time using the UltraGrid designer. But I'd like to be able to do this at runtime, so that I can associate the fields to different groups. Does anyone know if this is possible? I can create the groups dynamically, but how can fields be added to them?
Thanks,
Paul.
Hello Paul,
The Groups collection off of the UltraGridBand exposes an Columns.Add you can use to add columns.
Like so,
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0]; UltraGridGroup group1 = null; // Add group group1 = band.Groups.Add( "Group1", "Contacts" ); // Add column "ContactName" to the first level (level 0) of group1 with visible // position of 0 (meaning it will appear first in that level.) group1.Columns.Add( band.Columns["ContactName"], 0, 0 ); // Add City column to second level (level 1) with visible position of 0. group1.Columns.Add( band.Columns["City"], 0, 1 );
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0]; UltraGridGroup group1 = null;
// Add group group1 = band.Groups.Add( "Group1", "Contacts" );
// Add column "ContactName" to the first level (level 0) of group1 with visible // position of 0 (meaning it will appear first in that level.)
group1.Columns.Add( band.Columns["ContactName"], 0, 0 );
// Add City column to second level (level 1) with visible position of 0.
group1.Columns.Add( band.Columns["City"], 0, 1 );
Let me know if you have any questions regarding this matter.
Hi Michael,
Thank you for the code. Correct me if I'm, wrong, but in your example the columns are already added to the band, right? i.e in the line:
The "ContactName" column has already been added to the band? Do you have code showing how adding the column to the band can be done?
thanks,