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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
Public Class Form1
Dim l As New ArrayList
Dim i As Integer
Dim PCourant As Integer = 0
Dim Mode As Integer = 1
Dim Typ As String
Dim p As New place1
Dim f As New place2
Dim t As New place3
Dim r As New place4
Private Sub ButtonAfficher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MajDGV()
End Sub
Public Sub MajDGV()
DGV.Rows.Clear()
Dim i As Integer
For i = 0 To l.Count - 1
DGV.Rows.Add(l.Item(i).GetType.Name, l.Item(i).ToString)
Next
End Sub
Private Sub ButtonAjouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAjouter.Click
Mode = 1
ComboBox1.Visible = True
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Typ = ComboBox1.Text
GroupBox1.Visible = True
ComboBox1.Visible = False
GroupBox1.Text = "Nouveau " & ComboBox1.Text
End Sub
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
If Typ = "place1" Then
newplace1()
ElseIf Typ = "place2" Then
Newplace2()
ElseIf Typ = "place3" Then
newplace3()
ElseIf Typ = "place4" Then
newplace4()
End If
End Sub
Public Sub newplace1()
p.x = TextBoxX.Text
If Mode = 1 Then
l.Add(p)
ElseIf Mode = 2 Then
l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
End If
MajDGV()
End Sub
Public Sub Newplace2()
f.x = TextBoxX.Text
If Mode = 1 Then
l.Add(f)
ElseIf Mode = 2 Then
l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
End If
MajDGV()
End Sub
Public Sub Newplace3()
t.x = TextBoxX.Text
If Mode = 1 Then
l.Add(t)
ElseIf Mode = 2 Then
l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
End If
MajDGV()
End Sub
Public Sub Newplace4()
r.x = TextBoxX.Text
If Mode = 1 Then
l.Add(r)
ElseIf Mode = 2 Then
l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
End If
MajDGV()
End Sub
Private Sub ButtonModifier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonModifier.Click
Mode = 2
Typ = l.Item(DGV.CurrentRow.Index).GetType.Name
GroupBox1.Text = "Nouveau " & Typ
End Sub
Private Sub ButtonSupprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSupprimer.Click
l.RemoveAt(DGV.CurrentRow.Index)
MajDGV()
End Sub
Private Sub ButtonEnregistrer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEnregistrer.Click
End Sub
Public Sub enregistrer()
Dim f As FileStream = File.Create("fich.txt")
Dim s As New BinaryFormatter
s.Serialize(f, l)
f.Close()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim res As MsgBoxResult = MsgBox("voulez vous enregistrer", MsgBoxStyle.YesNoCancel, MsgBoxStyle.Exclamation)
If res = MsgBoxResult.Yes Then
enregistrer()
ElseIf res = MsgBoxResult.Cancel Then
e.Cancel = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MajDGV()
End Sub
End Class |
Partager