更新时间:2023-12-03 11:52:40
您可以使用VB.NET中的Split方法来实现此目的,请参阅下面的Split方法示例。假设用户单击其隐藏列id包含{1; 2; 3; 4; 5}的行,将ID拆分为数组,然后循环访问数组以获取每个单独的ID,并查询数据库以获取详细信息每个id。
You can use the Split method in VB.NET to achieve this, see a sample on this Split method below. Let say a user click a row where its hidden column ids contains {1;2;3;4;5}, split ids up into array, then loop thru the array to pick up each individual id, and query the database for detail of each id.
Dim ids As String
Dim i As Integer
Dim idArray() As String
ids = "1;2;3;4;5"
idArray = ids.Split(";")
For i = 0 To UBound(idArray)
'sql query to retrieve detail by id from database
MsgBox(idArray(i))
Next i
' replace ID's in Details_Explain with ShortCodes from DGV
For row = 0 To DGVOverzicht.Rows.Count - 1
Dim strDetailsExplain = ""
Dim DetailIDs As Array
DetailIDs = Split(DGVOverzicht.Rows(row).Cells("details").Value.ToString, ";")
For Each item In DetailIDs
If Not item = Nothing Then
strDetailsExplain = strDetailsExplain & DGV.Rows(Int(item)).Cells("DetailsCode").Value & ":"
End If
Next
DGVOverzicht.Rows(row).Cells("Details_Explain").Value = strDetailsExplain
Next
这就是我所做的,但它让它变得很慢,所以它不是首选的解决方案。
现在我已经决定'向他们展示ID那么......'的解决方案,因为它不会给PC和Dbase带来太多压力..所以感谢你的帮助,
你的解决方案是一个解决方案,所以我会接受它。
This is what I did, but it made it slow as hell, so it's not a preferred solution.
Right now I've settled for the 'show them the ID's then..' solution, because it does not invoke a lot of strain on the PC nor the Dbase.. so thanks for your help,
your solution was a solution, so I will accept it.