如何在Grideview上自动生成SN [英] How to auto generate SN on Grideview
本文介绍了如何在Grideview上自动生成SN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们
你好吗
我的问题是我在VB.net表单上有一个Datagrideview,如何通过添加新行Datagrideview自动生成序列号
希望我说得更清楚"
在Advanced
Dear, Budds
how are you
my issue is that i have a Datagrideview on my VB.net Form , how can i auto generate serial number by adding a new row Datagrideview
"I hope it more clear"
Thanks in advanced
推荐答案
中表示感谢,下面的代码演示了如何做到这一点.
只需要在下面的函数中传递datagridview,它将为表头单元格生成自动编号.
注意:首先,您必须将datagridview与数据绑定,然后调用以下函数.
below code shows how to do that.
Just you need to pass your datagridview in below function and it will generate auto number to Header cell.
NOTE: First you have to bind the datagridview with data then call the below function.
Public Sub AutoNumberRowsForGridView(ByVal dataGridView As DataGridView)
If dataGridView IsNot Nothing Then
Dim count As Integer = 0
While (count <= (dataGridView.Rows.Count - 2))
dataGridView.Rows(count).HeaderCell.Value = String.Format((count + 1).ToString(), "0")
count += 1
End While
End If
End Sub
或浏览此链接-
how-to-add-an-autonumber -column-in-a-datagridview/ [
Or Go through this link-
how-to-add-an-autonumber-column-in-a-datagridview/[^]
这篇关于如何在Grideview上自动生成SN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文