【问题标题】:DATAGRIDVIEW AND GRIDVIEW OF DEVEXPRESSDATAGRIDVIEW 和 DEVEXPRESS 的 GRIDVIEW
【发布时间】:2020-01-23 09:52:05
【问题描述】:

我在我的 erp 中使用 datagridview,但我的一位新客户要求我使用 devexpress

现在在datagridview中我使用如下代码

  Dim items As Boolean = False
        For Each row In DataGridView1.Rows
            If TextBox1.Text = row.Cells("Barcode").Value Then
                items = True
                Exit For
            End If
        Next

在“对于 DataGridView1.Rows 中的每一行”行中 我无法在 devexpress gridcontrol 中编写此代码。 我怎么能做到我的意思是我怎么能写出像“gridview.rows”这样的代码

我的完整代码是我想更改为 DEVEXPRESS --- GRIDVIEW

  If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then

        Dim items As Boolean = False

        ' For Each row In DATAGRIDVIEW.ROW

                     If DebitaccountTextEdit.Text = row.Cells("Barcode").Value Then


                items = True
                Exit For
            End If
        Next

        If items = False Then
            DataGridView1.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text)

            MessageBox.Show(Me, "Item Added to List", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information)


            TextBox1.Clear()
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
            TextBox5.Clear()
            TextBox6.Clear()

        Else
            MessageBox.Show(Me, "Item Already Added", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If
    End If

【问题讨论】:

    标签: devexpress vb.net-2010


    【解决方案1】:

    DevExpress GridView 没有 Rows 集合。您应该使用 for 循环遍历行。有关这方面的更多信息,请参阅Tutorial: Identifying Rows。例如:

    for (int i = 0; i < gridView1.RowCount; i++)
    {
         object barCodeValue = gridView1.GetRowCellValue(i, "Barcode");
    }
    

    使用 GridView 的 GetRowCellValue 方法根据字段/列名称和行索引检索单元格的值。

    使用 GridView 的 SetRowCellValue 根据字段/列名称和行索引设置单元格的值。

    另请参阅:Cell Values, Editors, and Validation

    【讨论】:

      猜你喜欢
      • 2016-03-28
      • 2014-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      • 1970-01-01
      • 2011-07-26
      • 2012-07-11
      相关资源
      最近更新 更多