1
Haga clic en el botón "Inicio " de Windows y seleccione la opción " Microsoft Visual Studio" .
2 Haga clic en " Abrir" y seleccione C + + programa en el que desea agregar una fila en el control DataGridView
3
agregue el código siguiente después de la " AutoAddNewRow : Form". línea en el programa C :
{
< p> AutoAddNewRow pública () {
InitializeComponent (); }
DataTable dt = new DataTable ();
void AutoAddNewRow_Load privada ( object sender , EventArgs e) {
dt.Columns.Add ("a" ) ;
dt.Columns.Add ( "b") ;
dt.Columns.Add ("c " , typeof ( int ));
for (int j = 0 ; j < 10 ; j + +) {
dt.Rows.Add ("a" + j.ToString (), " escddf " , j % 2 == 0 ) ;
}
this.dataGridView1 . DataSource = dt ;
}
dataGridView1_DefaultValuesNeeded private void ( object sender , DataGridViewRowEventArgs e)
{
e.Row.Cells [ "a" . ] Valor = " needa " ;
e.Row.Cells [ "b "] Valor = " needb " ; . .
e.Row.Cells [ "c "] = Valor cierto,
}
private void dataGridView1_CellBeginEdit ( object sender, DataGridViewCellCancelEventArgs e)
{
if ( e.RowIndex == this.dataGridView1.NewRowIndex )
{
valor de cadena = this.dataGridView1 [ e.ColumnIndex , Página 4
Haga clic en " Archivo", " Guardar" para agregar una fila en el control DataGridView de su C + + programa.