Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
Problem hiding rows in InitializeRow handler
posted

I have am having a problem hiding child rows of my self referencing table which are appearing in the root band.  I am handling the InitializeRow event and am checking to see if they should be children or root rows.  If they are children, I set e.Row.Hidden = true.  When running the application no rows are hidden.  If I set a break point in the event handler, then the rows will be hidden.  This seems very odd to me  can anyone give me some pointers on how to make these rows hide properly?  I am using 20083.2115.

Sample code below.

-Justin 

public Form1() {

  InitializeComponent();

  DataSet ds = new DataSet();

  DataTable dt = new DataTable();

  DataColumn dc = null;

  DataRow dr = null;

  dc = new DataColumn("ID", Type.GetType("System.Int32"));

  dt.Columns.Add(dc);

  dc = new DataColumn("ParentID", Type.GetType("System.Int32"));

  dt.Columns.Add(dc);

  dr = dt.NewRow();

  dr["ID"] = 1;

  dr["ParentID"] = DBNull.Value;

  dt.Rows.Add(dr);

  dr = dt.NewRow();

  dr["ID"] = 2;

  dr["ParentID"] = 1;

  dt.Rows.Add(dr);

  dr = dt.NewRow();

  dr["ID"] = 3;

  dr["ParentID"] = 1;

  dt.Rows.Add(dr);

  dt.TableName = "SelfReferencingTable";

  ds.Tables.Add(dt);

  ds.Relations.Add(ds.Tables["SelfReferencingTable"].Columns["ID"], ds.Tables["SelfReferencingTable"].Columns["ParentID"]);

 

  this.ultraGrid1.DisplayLayout.MaxBandDepth = 5;

  this.ultraGrid1.DataSource = ds;

}

private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) {

  // if i set a break point here, the rows will be hidden correctly

  // without a break point or simply running the .exe will not hide any rows

  if (e.Row.Band.ParentBand == null) {

    if (e.Row.Cells.HasCell("ParentID") && e.Row.Cells["ParentID"].Value != DBNull.Value) {

      e.Row.Hidden = true;

    }

  }

}