Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Description:
1. The datagridview(name is "grid") has three columns(ps: ID, FuelLeftKg, Model) and is databound of objects datasource.
2. When enter the newly row(ps: row head has both Arrow and * icons), will set the default values
C#
private void grid_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
   e.Row.Cells[1].Value = 0;		//FuelLeftKg
   e.Row.Cells[2].Value = "AirBus 350"; //Model
}

3. when enter the newly row's last cell(Model) via [TAB], I hope the other newly row will append to the datagridview last.
C#
private void grid_CellEnter(object sender, DataGridViewCellEventArgs e)
{
   if (grid.NewRowIndex == e.RowIndex && e.ColumnIndex == 2)
   {
         grid.CurrentRow.DataGridView.EndEdit();
         grid.EndEdit();
         CurrencyManager cm = (CurrencyManager)grid.BindingContext[grid.DataSource];
         cm.EndCurrentEdit();
   }
}

Qustion:
The newly row only set defualt value and move by [TAB] without any KEYIN. When enter the newly row last cell, there is
NO THE OTHER NEW ROW APPEND after the original newly row? Pls, help. Thanks!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900