我正在创建一个POS系统,但有些事情我无法获得销售表格。
它包含表的数据网格视图,其中包含列代码,描述,数量,总数。
我有一个查询执行此操作,但我不知道如何使查询将值返回到特定单元格。
订单付款后,我希望它以类似收据的方式记录所有数据。 (我不确定如果我应该有一个文本文件,将其记录在新表上,创建一个屏幕转储。)然后清理表中的所有内容,以便可以处理新的订单。
如何做到这一点?
答案 0 :(得分:1)
处理DataGridView上的CellValidated事件,然后检查哪个列已经过验证(使用e.ColumnIndex)。如果该列是代码或数量列,则可以检索该值并相应地更新其他列。
这是一个如何根据代码列的值更新描述列的例子,假设一个名为“MyDataGridView”的DataGridView,一个名为“CodeColumn”的Code列和一个名为“DescriptionColumn”的Description列:
Private Sub MyDataGridView_CellValidated(ByVal sender As Object, ByVal e As DataGridViewCellValidatingEventArgs) Handles MyDataGridView.CellValidated
If e.ColumnIndex = CodeColumn.Index Then
Dim code As String = MyDataGridView(e.ColumnIndex, e.RowIndex).Value.ToString()
Dim description As String = ' Get description using code '
MyDataGridView(DescriptionColumn.Index, e.RowIndex).Value = description
End If
End Sub