当单击单元格时,如何从Datagridview将空值返回到Datetimepicker Vb 10 [英] How Do I Return Blank Value From Datagridview To Datetimepicker When Cell Is Clicked Vb 10

查看:93
本文介绍了当单击单元格时,如何从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

[ ^ ]

推荐答案

好的...这是我的想法:

我会创建一个由您选择的函数调用的对话框。

对于此对话框,您可以通过属性提供相关信息。

在对话框内使用元素(DateTimePicker, TextBox,Combobox等)就像你现在这样做。

要离开Dialog,你有按钮Abort和OK,它给调用方法一个DialogResult。现在调用方法可以决定是否要进行更改。

在Dialog内部(可能使用Properties),您可以将一个空字符串传递给Dialog的调用者。 br $> b $ b

你明白我的意思吗??

你可以关注我还是需要进一步的信息?
OK ... this is my idea :
I would create a Dialog which is called by your selected functions.
To this Dialog you give the relevant Information(s) by Properties.
Inside the Dialog you work with the elements (DateTimePicker, TextBox, Combobox etc.) like you do it in the moment.
To leave the Dialog you have the Buttons "Abort" and "OK" which gave a DialogResult to the calling method. Now the calling method can decide, if you wish to take the changes or not.
Inside the Dialog (perhaps with the Properties) you are able to deliver an empty String to the caller of the Dialog.

Do you understand what I mean ...?
Could you follow me or do you need further Information ?


这篇关于当单击单元格时,如何从Datagridview将空值返回到Datetimepicker Vb 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆