VB.Net中如何把DataGridView中某一列的字段值的最大值放入textbox...
发布网友
发布时间:2024-10-23 14:58
我来回答
共3个回答
热心网友
时间:4分钟前
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(Me.DataGridView1.RowCount - 1) As Integer
For i As Integer = 0 To Me.DataGridView1.RowCount - 1
a(i) = Me.DataGridView1.Rows(i).Cells(1).Value '假设第1列吧
Next
Call Sort(a)
End Sub
Public Sub Sort(ByVal list As Integer())
Dim i As Integer, j As Integer, temp As Integer
Dim done As Boolean = False
j = 1
While (j < list.Length) AndAlso (Not done)
done = True
For i = 0 To list.Length - j - 1
If list(i) > list(i + 1) Then
done = False
temp = list(i)
list(i) = list(i + 1)
list(i + 1) = temp
End If
Next
j += 1
End While
Me.TextBox1.Text = list(Me.DataGridView1.RowCount - 1)
End Sub
热心网友
时间:8分钟前
是网页吗,网页用JS去实现好一些,尽量将一些可以前台实现的功能放到前台,减少服务器负拜担,如果是WINFROM 那还是用 licj12的方法吧 ,他的不错
热心网友
时间:5分钟前
DataGridView可以通过rows[i].column[j]获取每个单元格的值,遍历一下去最大的值吧