Hey everyone,
Heres my problem. I have 2 forms.
Form 1 contains a menu strip and data grid view
Form 2 Contains a Button and a bunch of other controls to help create the file.
How I'm doing this
Private Sub BtnRecord_Click(sender As Object, e As EventArgs) Handles BtnRecord.Click
Dim Bookz As String
Title = TxtTitle.Text
Author = TxtAuthor.Text
Stock = TxtStock.Text
Price = TxtPrice.Text
Genre = RadButFiction.Text
Genre2 = RadButNonFiction.Text
If TxtAuthor.Text = "" Or TxtPrice.Text = "" Or TxtTitle.Text = "" Or TxtStock.Text = "" Then
MessageBox.Show("Please fill in all required text boxes, they are marked with a * .")
ElseIf RadButFiction.Checked = False And RadButNonFiction.Checked = False Then
MessageBox.Show("Please select a category.")
ElseIf RadButFiction.Checked = True Then
Bookz = (Title & "," & Author & "," & Stock & "," & Price & "," & Genre)
Else
Bookz = (Title & "," & Author & "," & Stock & "," & Price & "," & Genre2)
End If
S = IO.File.AppendText("Booklistz.txt")
S.WriteLine(Bookz)
S.Close()
TxtTitle.Clear()
TxtAuthor.Clear()
TxtStock.Clear()
TxtPrice.Clear()
RadButFiction.Checked = False
RadButNonFiction.Checked = False
So I use a streamwriter which I dim as string in the public class to make it easier.
This code is working fine.
My problem is in this code, not so much a problem as much as I don't know how to go about doing it.
I use an openfiledialog to import the textfile which was created above into the datagridview.
I ran into several problems with this code, so if anyone could please guide me into how I would go about doing this. I would be greatly appreciative.
Dim textfile As String
Try
OpenFileDialog1.ShowDialog()
textfile = OpenFileDialog1.FileName
DGVBooks.DataSource = IO.File.ReadAllLines(textfile)
Catch ex As Exception
End Try
Novice at this I'm trying to import the data so it looks like the attached capture below ![bd1401fb65480c8bd92bea109464a0eb]
EDIT: I'm using VB.Net