Public Class Form1
Private Sub DVDBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DVDBindingNavigatorSaveItem.Click
Me.Validate()
Me.DVDBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DVDsDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO : cette ligne de code charge les données dans la table 'DVDsDataSet.DVD'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
Me.DVDTableAdapter.Fill(Me.DVDsDataSet.DVD)
'Laison du controle PictureBox à la source de données'
Me.PictureBox1.DataBindings.Add(New Binding("ImageLocation", Me.DVDBindingSource, "FichierImage", True))
End Sub
Private Sub DVDBindingSource_ListChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DVDBindingSource.ListChanged
If DVDBindingSource.Count = 0 Then
GroupBox1.Enabled = False
Else
GroupBox1.Enabled = True
If TitreTextBox.Text.Length = 0 Then
TitreTextBox.Focus()
End If
End If
End Sub
Private Sub Ouvrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ouvrir.Click
Dim OpenFileDialog As New OpenFileDialog
If OpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.ImageLocation = OpenFileDialog.FileName
End If
End Sub
Private Sub Supprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Supprimer.Click
PictureBox1.ImageLocation = String.Empty
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing (erreur)
'Arreter l'edition de la source de données'
Me.DVDBindingSource.EndEdit()
'Si il y a des changements, mettre à jour la base de données à l'aide du DVDTableAdpater'
If Me.DVDsDataSet.DVD.GetChanges() IsNot Nothing Then
Me.DVDTableAdapter.Update(Me.DVDsDataSet.DVD)
End If
End Sub
Private Sub Filtre_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Filtre.TextChanged
If Filtre.Text.Length > 2 Then
Me.DVDBindingSource.Filter = String.Format("{0} like '%{1}%' or {2} like '%{1}%'", Me.DVDsDataSet.DVD.TitreColumn.ColumnName, Me.Filtre.Text, Me.DVDsDataSet.DVD.DescriptionColumn.ColumnName)
End If
End Sub
End Class
|