I have a Problem with my Modified Event
As you can See !
i know My declarations are Private I tried Some thing still didn't work
So what i want to do as you can see is that if the save button was not clicked then
it would check if the listbox2 larger is than the myproccesesCurrentnumber
Then you see Msgbox's about saving bla bla bla
But Here's the problem if i open the Form again and close it again without making changes it would Pop up the Modified Event which it should not do since i never modified it so what gives !! why is this happening :|
Plus the declarations values are Restored as Normal each time on Form load so
it's not saving the values so how is this Possible :angry:
Private myprocessesCurrentNumber As Integer
Private CLickedSAvebuttonOnOpen As Integer
Private Sub Form3_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If Me.ListBox2.Items.Count > myprocessesCurrentNumber Then
If CLickedSAvebuttonOnOpen = 0 Then
If MessageBox.Show("<1> Storage / History Box Has been Modified and has not Been saved to History / Storage File !!!" & vbNewLine & "<2> Would you like to save The Modified Data?", "*Error - Not Saved*", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
Button2.PerformClick()
Else
MsgBox("Saved Option was Cancelled by User", MsgBoxStyle.Information, "Save Cancelled")
End If
Else
End If
Else
End If
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
Timer2.Start()
myprocessesCurrentNumber = ListBox2.Items.Count <<<
CLickedSAvebuttonOnOpen = 0 <<<
ListBox1.ContextMenuStrip = ContextMenuStrip1
ListBox2.ContextMenuStrip = ContextMenuStrip2
UpdateProcessList()
ListBox2.Items.Clear()
Dim WoofRead = New IO.StreamReader(MySettingfil)
While (WoofRead.Peek() > -1)
ListBox2.Items.Add(WoofRead.ReadLine)
End While
WoofRead.Close()
End Sub
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
CLickedSAvebuttonOnOpen = 1 <<<
If Me.CheckBox1.Checked Then
Dim myCoolWriter As New IO.StreamWriter(MySettingfil)
For i As Integer = 0 To ListBox2.Items.Count - 1
myCoolWriter.WriteLine(ListBox2.Items(i).ToString)
Next
myCoolWriter.Close()
Me.Dispose()
Else
Dim myCoolWriter As New IO.StreamWriter(MySettingfil)
For i As Integer = 0 To ListBox2.Items.Count - 1
myCoolWriter.WriteLine(ListBox2.Items(i).ToString)
Next
myCoolWriter.Close()
End If
Catch Save As Exception
End Try