tags:

views:

85

answers:

2

private void showdate(DataGridViewCellEventArgs e) {

        dateTimePicker1.Size = vacation_transDataGridView.CurrentCell.Size;
        dateTimePicker1.Top = vacation_transDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Top + vacation_transDataGridView.Top;
        dateTimePicker1.Left = vacation_transDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Left + vacation_transDataGridView.Left;


        if (!(object.Equals(Convert.ToString(vacation_transDataGridView.CurrentCell.Value),"")))
        {
            dateTimePicker1.Value = Convert.ToDateTime(vacation_transDataGridView.CurrentCell.Value);
            //dateTimePicker1.Visible = false;
        }
        dateTimePicker1.Visible = true;
    }

this code in dgv cell_click event

A: 

Unfortunately there isn't such a Cell or Column Type you can use (as far as i know). But Microsoft provides an example on how to get a NumericUpDown (that also doesn't exist) into a DataGridView.

Maybe you can adopt this example to get your DateTimePicker into a DataGridView.

Oliver
thanks mins i am found another solution
shmandor
If you found another solution you should post it here (if it is a real answer to your question) or just delete your question.
Oliver
i am found solution says you can in dgv_cellclick event call datetimepicker with the same size and location of the cell whats your opnion for this
shmandor
dateTimePicker1.Size = vacation_transDataGridView.CurrentCell.Size; dateTimePicker1.Top = vacation_transDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Top + vacation_transDataGridView.Top; dateTimePicker1.Left = vacation_transDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Left + vacation_transDataGridView.Left;
shmandor
@shmandor: Well that's a fast and hacky way to solve your problem, but if it works as you expected, than it's okay. Maybe you can edit your question and add your code below it. Thus making it more easily to read than in a comment.
Oliver
A: 

There is an example of exactly this thing on MSDN. http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

Chris McKenzie
thanks chris mckenzie its right answer
shmandor