请教个DataGridView在虚拟模式下DataBindingComplete事件的问题
DataGridView有一个计算的列,必须启动虚拟模式(Virtual Mode=True),然后用CellValueNeeded事件计算。下面这段代码在没启动虚拟模式时,是可以看到图片自动加载到指定列的效果的,但一启动虚拟模式,图片就无法加载,请求在启动虚拟模式解决图片加载显示的代码,谢谢。
Private Sub DataGridViewx1_DataBindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles DataGridViewx1.DataBindingComplete
Dim image1 As Image = Nothing
Dim image2 As Image = Nothing
Dim path As String = String.Empty
For i As Integer = 0 To DataGridViewX1.Rows.Count - 1
path = Application.StartupPath & "\" & DataGridViewX1.Rows(i).Cells("照片路径").Value
If File.Exists(path) Then
image1 = Image.FromFile(path)
image2 = New Bitmap(image1, 120, 120)
DirectCast(DataGridViewX1.Rows(i).Cells("Pic"), DataGridViewImageCell).Value = image2
End If
Next
End Sub --------------------编程问答-------------------- 得,还是老老实实的在DataBindingComplete计算那个列吧,数据不多,不虚拟模式了
补充:.NET技术 , VB.NET