I want to add column and group to wingrid on runtime using the following codes.
But there is a bug. When the first time ChangeGroup function was invoked, the groups won't displayed, and if I use some method trying to get the group object, it throws an error. And when the ChangeGroup function was invoked by the second time and right after, the bug won't be exist any more, I don't what cause this bug.
If somebody tell me? Thank you!
AddGroups ag = new AddGroups();ag.ChangeGroup(ultraGridShareholderRight,ht);
public class AddGroups { public void ChangeGroup( UltraGrid ultraGridZYYWSR, Hashtable ht) { String dataType = ht["datatype"].ToString(); String startYear = ht["startyear"].ToString(); String endYear = ht["endyear"].ToString(); String startNum = ht["startnum"].ToString(); String endNum = ht["endnum"].ToString(); ultraGridZYYWSR.DisplayLayout.Bands[0].Groups.Add(columnName1, ""); ultraGridZYYWSR.DisplayLayout.Bands[0].Columns.Add(columnName1, columnName1); ultraGridZYYWSR.DisplayLayout.Bands[0].Columns.Add("F_GSID", "F_GSID"); ultraGridZYYWSR.DisplayLayout.Bands[0].Columns["F_GSID"].Hidden = true; ultraGridZYYWSR.DisplayLayout.Bands[0].Columns[columnName1].Width = 80; ultraGridZYYWSR.DisplayLayout.Bands[0].Columns[columnName1].Group = ultraGridZYYWSR.DisplayLayout.Bands[0].Groups[columnName1]; if (dataType == "y") { int num = 0; int i = 0; for (i = Int32.Parse(endYear); i >= Int32.Parse(startYear) - 1; i--, num++) { ultraGridZYYWSR.DisplayLayout.Bands[0].Groups.Add(i.ToString(), i.ToString() + "Year"); ultraGridZYYWSR.DisplayLayout.Bands[0].Groups[i.ToString()].Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Center; String columnNum = "Num" + num; ultraGridZYYWSR.DisplayLayout.Bands[0].Columns.Add(columnNum, "Num");
ultraGridZYYWSR.DisplayLayout.Bands[0].Columns[columnNum].Group = ultraGridZYYWSR.DisplayLayout.Bands[0].Groups[i.ToString()]; ultraGridZYYWSR.DisplayLayout.Bands[0].Columns[columnNum].Width = 100; } ultraGridZYYWSR.DisplayLayout.Bands[0].Groups[(i + 1).ToString()].Hidden = true; } }
Please remember that these forums area a peer-to-peer resource to share issues and ideas with other Infragistics users. If you require official support from Infragistics, particularly to report a possible bug in one of our products, please submit a support incident to Infragistics Developer Support from this page of our website.To help investigate this issue, Developer Support will likely also need from you a sample project that we can run and debug which demonstrates the problem.