多图像如何显示在带有数据网格视图中文件名的图片框中
how multi images appear in the Picture box with the file name in the datagridview
我想在单击datagridview时在datagridview中的文件名的图片框中显示多个或单个图像。
我使用的信息 visual studio 2010
Imports System.Data.OleDb
Public Class Form1
Dim Path As String = "C:\Users\Administrator\Desktop\DBF"
Dim Pathimage As String = "C:\Users\Administrator\Desktop\CATALOG"
Dim cn = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Private Sub PopulateDataGridView()
Try
Dim dt = New DataTable()
Dim query = "select ITM,ITC,QOH,PRS,FILENAME1,FILENAME2,FILENAME3,FILENAME4 FROM ITEM"
Using adapter As New OleDbDataAdapter(query, cn.ToString)
adapter.Fill(dt)
End Using
Me.DataGridView1.DataSource = dt
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PopulateDataGridView()
End Sub
End Class
将 FlowLayoutPanel 添加到您的表单,并将此处理程序粘贴到 DataGridView1 SelectionChanged
Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
Dim row = DirectCast(DataGridView1.CurrentRow.DataBoundItem, DataRowView)
Dim pbAdder =
Sub(name As String)
If row(name) IsNot Nothing AndAlso Not String.IsNullOrEmpty(row(name).ToString()) Then
FlowLayoutPanel1.Controls.Add(New PictureBox With {.Name = name, .ImageLocation = row(name).ToString()})
End If
End Sub
FlowLayoutPanel1.Controls.Clear()
pbAdder("FILENAME1")
pbAdder("FILENAME2")
pbAdder("FILENAME3")
pbAdder("FILENAME4")
End Sub
我想在单击datagridview时在datagridview中的文件名的图片框中显示多个或单个图像。
我使用的信息 visual studio 2010
Imports System.Data.OleDb
Public Class Form1
Dim Path As String = "C:\Users\Administrator\Desktop\DBF"
Dim Pathimage As String = "C:\Users\Administrator\Desktop\CATALOG"
Dim cn = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Private Sub PopulateDataGridView()
Try
Dim dt = New DataTable()
Dim query = "select ITM,ITC,QOH,PRS,FILENAME1,FILENAME2,FILENAME3,FILENAME4 FROM ITEM"
Using adapter As New OleDbDataAdapter(query, cn.ToString)
adapter.Fill(dt)
End Using
Me.DataGridView1.DataSource = dt
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PopulateDataGridView()
End Sub
End Class
将 FlowLayoutPanel 添加到您的表单,并将此处理程序粘贴到 DataGridView1 SelectionChanged
Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
Dim row = DirectCast(DataGridView1.CurrentRow.DataBoundItem, DataRowView)
Dim pbAdder =
Sub(name As String)
If row(name) IsNot Nothing AndAlso Not String.IsNullOrEmpty(row(name).ToString()) Then
FlowLayoutPanel1.Controls.Add(New PictureBox With {.Name = name, .ImageLocation = row(name).ToString()})
End If
End Sub
FlowLayoutPanel1.Controls.Clear()
pbAdder("FILENAME1")
pbAdder("FILENAME2")
pbAdder("FILENAME3")
pbAdder("FILENAME4")
End Sub