Click here to Skip to main content
15,904,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. All


Here i USe Code For DGV Paricular Columns Only Want to SHOW DTP.. But this code show all columns.


How can i Change Paricular Columns..


VB
dtpCell = New DateTimePicker
        dtpCell.Visible = False
        AddHandler dtpCell.ValueChanged, AddressOf DateTimePickerCell_ValueChanged
        'DGV1.Columns.Add("col1", String.Empty)
         DGV1.Controls.Add(dtpCell)
        AddHandler DGV1.CellBeginEdit, AddressOf DataGridView_CellBeginEdit
        AddHandler DGV1.CellEndEdit, AddressOf DataGridView_CellEndEdit




VB
Private Sub DataGridView_CellBeginEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellCancelEventArgs)
       Dim tmpRect As Rectangle = DirectCast(sender, DataGridView).GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True)
       dtpCell.Location = tmpRect.Location
       dtpCell.Width = tmpRect.Width
       dtpCell.Visible = True
   End Sub

   Private Sub DataGridView_CellEndEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs)
       dtpCell.Visible = False
   End Sub

   Private Sub DateTimePickerCell_ValueChanged(sender As Object, e As EventArgs)
       DirectCast(sender.parent, DataGridView).CurrentCell.Value = Convert.ToDateTime(dtpCell.Value).Date.ToString("dd MMM yyyy")
       dtpCell.Visible = False
       DirectCast(sender.parent, DataGridView).EndEdit()
   End Sub


Please Tell When i Click my DGV DOB Column Click time show to DTP..
Posted

1 solution

VB
Private Sub DataGridView_CellBeginEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellCancelEventArgs)
    If Me.DataGridView1.Focused AndAlso Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
        Dim tmpRect As Rectangle = DirectCast(sender, DataGridView).GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True)
        dtpCell.Location = tmpRect.Location
        dtpCell.Width = tmpRect.Width
        dtpCell.Visible = True
    End If
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900