且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在vb.net中自动设置标签文本

更新时间:2021-09-29 01:19:08

您在代码中的某个时刻选择了Label从网格的第一行开始。在设置如下值之前,您只需要从每一行获取控件:

You have at some point in your code selected the Label from the first row in your grid. You simply need to grab the control from each row before you set the value like this:
For Each row As DataGridViewRow In FormulativeDV.Rows
   If Not row.IsNewRow Then
      Label lblCtl = (Label)row.FindControl("LabelName")
      If Not lblCtl = Nothing Then
         lblCtl.Text = (row.Cells(0).Value.ToString)
      End If
   End If
Next