devexpress - DATAGRIDVIEW 和 DEVEXPRESS 的 GRIDVIEW
问题描述
我在我的 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 GridView 没有 Rows 集合。您应该使用 for 循环遍历行。有关这方面的更多信息,请参阅教程:识别行。例如:
for (int i = 0; i < gridView1.RowCount; i++)
{
object barCodeValue = gridView1.GetRowCellValue(i, "Barcode");
}
使用 GridView 的GetRowCellValue方法根据字段/列名称和行索引检索单元格的值。
使用 GridView 的SetRowCellValue根据字段/列名称和行索引设置单元格的值。
另请参阅:单元格值、编辑器和验证
推荐阅读
- fpga - Chisel3 REPL peek 值正确,但预计测试失败
- netty - 如何控制用于读取的缓冲区网络?
- git - 如何删除 git 终端上显示的未跟踪更改和已删除文件
- javascript - 有没有办法使用反应将 html 元素从 div 移动到另一个 div?
- php - 子域作为 .htaccess 中的参数,而 php 不起作用
- intellij-idea - intellij 控制台抑制终端中的警告
- javascript - 如何在无需单击的情况下确定鼠标位置是否与图像相同?JS
- c# - TMPro 是一个命名空间,但用作 Unity 类型
- flutter - 在 Flutter 中运行 GLSL 着色器
- json - 如何使用 PowerShell 从 json 响应中获取单个值