本文介绍了当单击单元格时,如何从Datagridview将空值返回到Datetimepicker Vb 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是我的代码:
here my code :
'for clear the date value
Sub clear()
dtpDOJ.Text = " "
End sub
'for return value to datetime picker when datagridview is clicked
Private Sub dgvdatakaryawan_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvdatakaryawan.CellContentClick
Dim i As Integer
Dim n As Integer = dgvdatakaryawan.Rows.Count
If n = 0 Then
Call clear()
Else
Try
i = dgvdatakaryawan.CurrentRow.Index
dtpDOJ.Text = dgvdatakaryawan.Item(1, i).Value
Catch ex As Exception
End Try
End If
End Sub
'this is property of datetimepicker
Private Sub dtpDOJ_ValueChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpDOJ.ValueChanged
Me.dtpDOJ.Format = Windows.Forms.DateTimePickerFormat.Custom
Me.dtpDOJ.CustomFormat = "dd MMMM yyyy"
End Sub
[]
推荐答案
这篇关于当单击单元格时,如何从Datagridview将空值返回到Datetimepicker Vb 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!