Salvete!好吧,在经历了一些艰难的痛苦之后,我找到了答案。
首先,我硬编码表格中的列结构,而不是动态加载它。我不会需要更多的csv文件中的列数据,所以这是我的选择。但是,这允许我精确地指定哪些列是图像列,哪些是文本列,它让我可以在VS的GUI设计器中完成所有这些。
当我加载csv时,我创建了两个额外的图像列,并将其相应的数据值设置为不可见。
后来,当我保存csv文件时,我跳过图像行并保存数据行中的内容。
Private Sub ImportCSV(ByVal whatgrid As DataGridView, ByVal whatfile As String)
Dim TextLine As String = ""
Dim SplitLine() As String
whatgrid.Rows.Clear()
Dim thisobject0 As Object
Dim thisobject1 As Object
If System.IO.File.Exists(whatfile) = True Then
Dim objReader As New System.IO.StreamReader(whatfile)
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
SplitLine = Split(TextLine, ",")
If SplitLine(0) = "false" Then thisobject0 = My.Resources.markfalse Else If SplitLine(0) = "true" Then thisobject0 = My.Resources.marktrue Else thisobject0 = My.Resources.blank
If SplitLine(1) = "false" Then thisobject1 = My.Resources.markfalse Else If SplitLine(1) = "true" Then thisobject1 = My.Resources.marktrue Else thisobject1 = My.Resources.blank
whatgrid.Rows.Add(thisobject0, SplitLine(0), thisobject1, SplitLine(1), SplitLine(2), SplitLine(3))
Loop
objReader.Close()
blankNewRow()
Else
MsgBox("File Does Not Exist")
End If
End Sub