private void textBox1_Click(object sender, EventArgs e)
 {
     if (curr == null) { return; }
     if ((curr.type == Field.DATE) || (curr.type == Field.DATETIME))
     {
         DateDialog d = new DateDialog((curr.type == Field.DATETIME));
         if (d.ShowDialog() == DialogResult.OK)
         {
             if (curr.type == Field.DATETIME)
             {
                 textBox1.Text = d.result;
             }
             else
             {
                 textBox1.Text = d.date;
             }
         }
     }
 }
        private void dataGrid_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            int type=table.columns[e.ColumnIndex].type;
            if ((type == Field.DATE) || (type == Field.DATETIME))
            {
                e.Cancel = true;
                DateDialog d = new DateDialog((type == Field.DATETIME));
                if (d.ShowDialog() == DialogResult.OK)
                {
                    if (type == Field.DATETIME)
                    {
                        dataGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = d.result;
                    }
                    else
                    {
                        dataGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = d.date;
                    }

                    dataGrid_CellEndEdit(sender, new DataGridViewCellEventArgs(e.ColumnIndex, e.RowIndex));
                }
            }
        }
 private void NFdate_Click(object sender, EventArgs e)
 {
     DateDialog d = new DateDialog(true);
     if (d.ShowDialog() == DialogResult.OK)
     {
         TextBox t = (TextBox)(sender);
         t.Text = d.result;
     }
 }