private void Form2_Load(object sender, System.EventArgs e)
{
flyGrid1.Columns.Items.Add( new Column(\"Column0\") );
flyGrid1.Columns.Items.Add( new Column(\"Column1\") );
flyGrid1.Columns.Items.Add( new Column(\"Column2\") );
flyGrid1.Columns.Items.Add( new Column(\"Column3\") );
flyGrid1.Columns.Items.Add( new Column(\"Column4\") );
flyGrid1.Rows.Items.Add(new Node(new object[] { 0, 1, 2, 3, 4 }));
flyGrid1.Rows.Items.Add(new Node(new object[] { 0, 1, 2, 3, 4 }));
flyGrid1.Rows.Items.Add(new Node(new object[] { 0, 1, 2, 3, 4 }));
flyGrid1.Rows.Items.Add(new Node(new object[] { 0, 1, 2, 3, 4 }));
flyGrid1.Rows.Items.Add(new Node(new object[] { 0, 1, 2, 3, 4 }));
}
private bool flyGrid1_NodeCellChanging(object sender, NineRays.Windows.Forms.Data.NodeBase node, int index, ref object value)
{
MessageBox.Show(index.ToString());
return true;
}
private void button1_Click(object sender, System.EventArgs e)
{
flyGrid1.Rows.Items.Clear();
int FixedColumnsNumber = 1;
Column[] toRemove = new Column[flyGrid1.Columns.Items.Count - FixedColumnsNumber];
for(int i=FixedColumnsNumber; i toRemove[i-FixedColumnsNumber] = flyGrid1.Columns.Items[i];
for(int i=0; i flyGrid1.Columns.Items.Remove(toRemove[i]);
flyGrid1.Columns.Items.Add( new Column(\"ColumnX\") );
flyGrid1.Rows.Items.Add(new Node(new object[] { 0, 99 }));
}
}
}
Build the project and start the application.
The application form contains 5 columns and several rows. The values in cells could be edited correctly and message box displays correct column index each time the NodeCellChanging event is being fired.
Now click on the button.
There are now only two columns in the grid, the second one contains empty values in its cells, although they were properly provided.
Try to edit empty cells in the ColumnX column.
The message box displays an index value, which is greater then the number of columns in the grid.
The index passed to the NodeCellChanging event should be valid and the column ColumnX must display values correctly.
Could you please fix this issue?
Thank you.
PS: Tested with the last 1.4.0.24 version.