VB.Net中如何把DataGridView中某一列的字段值的最大值放入textbox中?
展开全部
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
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
展开全部
是岁陆贺网页吗,网页用JS去实现好一些,尽量将一些可以前台实现的功能放到前台乎派,减少服务器负拜担,如果是WINFROM 那还是用 licj12的方法吧 ,他的悉拦不错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
DataGridView可以通过rows[i].column[j]获取每个单州薯并耐元格的值,遍册蔽者历一下去最大的值吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询