学习总结
1、了解了表属性中datacolchanged事件
2、会简单的写代码了
3、在datacolchanged事件中加了2个功能,实现了年龄和照片的自动输入
4、代码上传,请高手检查、改进
If e.DataCol.Name = "身份证号码" Then '如果更改的是身份证号码列
If e.DataRow.IsNull("身份证号码") Then '身份证号码是否为空
e.DataRow("出生日期") = Nothing '如果为空,则清除出生日期
e.DataRow("性别") = Nothing
e.DataRow("年龄") = Nothing
Else
'否则从身份证号码列中提取出生日期
e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号码"))
e.DataRow("性别") = ReadSex(e.DataRow("身份证号码"))
e.DataRow("年龄") = Date.Today.year - ReadBirthday(e.DataRow("身份证号码")).year
End If
End If
If e.DataCol.name ="姓名" Then
If e.DataRow.Isnull("姓名") Then
e.DataRow("照片") = Nothing
Else
e.DataRow("照片") = e.DataRow("姓名")+"."+"JPG"
End If
End If