DataGridView验证字段

时间:2016-05-10 10:03:52

标签: vb.net

拥有绑定到数据源的datagridview。还可以为用户添加新行。用户可以修改所有行字段以及添加包含数据的新行。我的目标是验证一些事情:

1. Check whether all fields have been filled out
2. Check whether correct values type's have been typed by user
3. Check whether new row ("if touched") has been filled also correctly.

表格字段为:

Id (hided)
Name (string)
Lage (string)
Wahrung (string)
Nummer (integer)
Date (date)

目前我所拥有的是:

从数据源加载数据

 Private hersteller As Hersteller

    Private Sub FrmProducents_Load(sender As Object, e As EventArgs) Handles MyBase.Load
         InitGrid()
    'due to not run it during first grid bind from datasource
    AddHandler Grid.RowValidating, AddressOf Grid_CellValidating
    End Sub

    Private Sub InitGrid()
         hersteller = New Hersteller
         Grid.DataSource = hersteller.GetHerstellerDS.Tables(0)
    End Sub

    Private Sub Grid_CellValidating()
         'Suppose every logic to be implemented here
    End Sub

0 个答案:

没有答案