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
249
Insert Row at specific index
posted

Hi I am trying to insert a row in a databound grid at a specific index. I tried this in the following way:

private void HierarchyGrid_Load(object sender, EventArgs e)

{

BindingList<Pool> data = DummyDataBuilder.BuildDummyData();

TestGridMain.DataSource = data;

TestGridMain.DataBind();

InsertSpecificRow();

}

 private void InsertSpecificRow()

 {

      var position =0;

      var row = TestGridMain.DisplayLayout.Bands[1].AddNew();

      row.Cells["Name"].SetValue("Bla bla bla", false);

      row.Appearance.BackColor = Color.Pink;

      TestGridMain.Rows.Move(row, position);

 }

Now whatever value I give position, the row is always at the bottom. I even added a button to the form invoking the Rows.Move on a specific row and I checked the row's index before and after the move instruction: no change.

Is there a setting in the grid that is preventing my rows from moving? Did I miss something elsewhere?

Thanks,

Teun

P.S. Sorry for ugly code: What is the correct way for mark up?

Parents Reply Children
No Data