private void button4_Click(object sender, EventArgs e) { //Satır Sil butonu try { //Liste güncellenir TeklifList = Teklif.teklif_listesi_olustur(dt); if (dataGridView1.SelectedRows.Count != 0) { foreach (DataGridViewRow row in dataGridView1.SelectedRows) { dataGridView1.Rows.Remove(row); } //Datatable güncellenir dt.AcceptChanges(); } else { MessageBox.Show("Lütfen silinecek satırı seçiniz.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (NullReferenceException exception) { MessageBox.Show("Satır seçilmedi"); } catch (System.Exception exception) { MessageBox.Show("Bir hata meydana geldi.ERROR=" + exception.Message); } }
//Comboboxtan seçilen Excel sayfasını Datatable'dan Datagridview'e aktarma private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { dt = dTable[comboBox1.SelectedIndex]; dataGridView1.DataSource = dt; TeklifList = Teklif.teklif_listesi_olustur(dt); //Listeden Datagirdview' e aktarma //dataGridView1.DataSource = Teklif.teklif_listesi_olustur(dt); }
//Sayfayı Güncelle butonu private void button2_Click(object sender, EventArgs e) { //Datagridview'deki verileri Datatable'a aktarır DataTable dt = new DataTable(); foreach (DataGridViewColumn col in dataGridView1.Columns) { dt.Columns.Add(col.Name); } foreach (DataGridViewRow row in dataGridView1.Rows) { DataRow dRow = dt.NewRow(); foreach (DataGridViewCell cell in row.Cells) { dRow[cell.ColumnIndex] = cell.Value; } dt.Rows.Add(dRow); } //Listeyi güncelleme TeklifList = Teklif.teklif_listesi_olustur(dt); }