private void dgDatos_CellClick(object sender, DataGridViewCellEventArgs e) { int indice = e.RowIndex; ClPersona personaSeleccionada = ((ClPersona)(dgDatos.Rows[indice].DataBoundItem)); txtNombre.Text = personaSeleccionada.Nombre; txtidentificacion.Text = personaSeleccionada.Identificacion.ToString(); dtFechaNacimiento.Text = personaSeleccionada.FechaNacimiento; }
private void btnEliminar_Click(object sender, EventArgs e) { int indicePersona = ListaPersonas.FindIndex(F => F.Identificacion == int.Parse(txtidentificacion.Text)); ClPersona PersonaEliminar = ListaPersonas[indicePersona]; ListaPersonas.Remove(PersonaEliminar); dgDatos.DataSource = null; dgDatos.DataSource = ListaPersonas; txtNombre.Text = ""; txtidentificacion.Text = ""; }
private void btnModificar_Click(object sender, EventArgs e) { int indicePersona = ListaPersonas.FindIndex(F => F.Identificacion == int.Parse(txtidentificacion.Text)); ClPersona PersonaEditar = ListaPersonas[indicePersona]; PersonaEditar.Nombre = txtNombre.Text; ListaPersonas[indicePersona] = PersonaEditar; dgDatos.DataSource = null; dgDatos.DataSource = ListaPersonas; }
private void btnGuardar_Click(object sender, EventArgs e) { ClPersona oPersona = new ClPersona(); oPersona.Nombre = txtNombre.Text; oPersona.Identificacion = int.Parse(txtidentificacion.Text); oPersona.FechaNacimiento = dtFechaNacimiento.Text; ListaPersonas.Add(oPersona); dgDatos.DataSource = null; dgDatos.DataSource = ListaPersonas; txtNombre.Text = ""; txtidentificacion.Text = ""; }