






Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!







using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace examennombre { public partial class Form1 : Form { Database1Entities contexto; public Form1() { InitializeComponent(); } private void limpiartextos() { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; } private void llenargrid() { try { contexto = new Database1Entities(); var datos = from a in contexto.Tables select new { idcurp = a.Idcurp, nombre = a.nombre, apellido = a.apellido }; dataGridView1.DataSource = datos.ToList(); // dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnMode.Fill; } catch (Exception ex) { MessageBox.Show("ocurrio un error:" + ex.ToString()); } } private void button1_Click(object sender, EventArgs e) { try { contexto = new Database1Entities(); Table table = new Table() { Idcurp = textBox1.Text, nombre = textBox2.Text, apellido = textBox3.Text, }; contexto.Tables.Add(table); contexto.SaveChanges(); MessageBox.Show("registro agregado"); limpiartextos(); llenargrid(); } catch(Exception ex) { MessageBox.Show("ocurrio un error:" + ex.ToString()); } } }}