1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
//dropper sur le form:
//-01 dataset personnalise
//-01 dataadapter personnalise
//- 04 buttons
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinDGVSearch
{
public partial class Form2 : Form
{
BindingSource bindingproduction_planifier = new BindingSource();
public Form2()
{
InitializeComponent();
}
private void btnFillDataTable_Click(object sender, EventArgs e)
{
personsTableAdapter1.Fill(personsDataSet1.Persons);
bindingproduction_planifier.DataSource = personsDataSet1;
bindingproduction_planifier.DataMember = personsDataSet1.Persons.TableName;
this.label1.DataBindings.Add(new Binding("Text", bindingproduction_planifier.DataSource , "Persons.Nom", true, DataSourceUpdateMode.OnPropertyChanged));
this.label2.DataBindings.Add(new Binding("Text", bindingproduction_planifier.DataSource, "Persons.Prenom", true, DataSourceUpdateMode.OnPropertyChanged));
}
private void btnMoveNext_Click(object sender, EventArgs e)
{
bindingproduction_planifier.MoveNext();
DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
this.label1.Text = drview.Row["Nom"].ToString();
this.label2.Text = drview.Row["Prenom"].ToString();
this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
}
private void btnMovePrevious_Click(object sender, EventArgs e)
{
bindingproduction_planifier.MovePrevious();
DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
this.label1.Text = drview.Row["Nom"].ToString();
this.label2.Text = drview.Row["Prenom"].ToString();
this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
}
private void btnAddNew_Click(object sender, EventArgs e)
{
//se position sur le dernier record ....
bindingproduction_planifier.MoveLast();
//ajout nouveau record à la vue....
bindingproduction_planifier.AddNew();
DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
drview.Row["Nom"]="adel";
drview.Row["Prenom"] = "moustansir";
//se position sur le record ajoute....
bindingproduction_planifier.MoveNext();
this.label1.Text = drview.Row["Nom"].ToString();
this.label2.Text = drview.Row["Prenom"].ToString();
this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
}
}
} |
Partager