this is what I have for Form Closing event.
Private Sub frmShopDisplay_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim response As MsgBoxResult
response = MsgBox("Do you want to close without saving changes?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm")
If response = Windows.Forms.DialogResult.No Then
e.Cancel = True
End If
End Sub
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
Dim fileName As String = ""
Dim dlgSave As New SaveFileDialog
dlgSave.Filter = "Text files (*.txt)|*.txt|CSV Files (*.csv)|*.csv"
dlgSave.AddExtension = True
dlgSave.DefaultExt = "txt"
If dlgSave.ShowDialog = Windows.Forms.DialogResult.OK Then
fileName = dlgSave.FileName
SaveToFile(fileName)
End If
End Sub
Private Sub SaveToFile(ByVal fileName As String)
If DataGridView1.RowCount > 0 AndAlso DataGridView1.Rows(0).Cells(0) IsNot Nothing Then
Dim stream As New System.IO.FileStream(fileName, IO.FileMode.Append, IO.FileAccess.Write)
Dim sw As New System.IO.StreamWriter(stream)
For Each row As DataGridViewRow In DataGridView1.Rows
Dim line As String
line = row.Cells(0).ToString()
line &= ";" & row.Cells(1).ToString()
line &= ";" & row.Cells(2).ToString()
line &= ";" & row.Cells(3).ToString()
line &= ";" & row.Cells(4).ToString()
line &= ";" & row.Cells(5).ToString()
line &= ";" & row.Cells(6).ToString()
line &= ";" & row.Cells(7).ToString()
Next
sw.Flush()
sw.Close()
End If
End Sub
My combo boxes seem fine..they are displaying in the datagridview that I have but just in case, here is my combobox code ..or at least one of them..LOL...I got 8 of em, and they are all named matching the datagrid columns.