我现在想对DATAGRIDVIEW,如果DATAGRIDVIEW的某一列为日期类型,那么当双击时弹出datetimePiker控件,现在问题是,如何知道双击单元格所属的那一列是否为日期类型?

解决方案 »

  1.   

    列上有个属性,记不清了 ,应该是DataType
      

  2.   


             private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
             {
                 if (dataGridView1.Columns[e.ColumnIndex].ValueType == typeof(DateTime))
                 {
                     //...
                 }             //if (dataGridView1[e.ColumnIndex, e.RowIndex].ValueType == typeof(DateTime))
                 //{
                 //    //...
                 //}
             }
      

  3.   

    DateTimePicker dp = new DateTimePicker();  
    dataGridView1.Controls.Add(dp);   
    private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
    {
      if (dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "")
      {
    }
    }
    http://topic.csdn.net/u/20091118/22/bab1a71a-21e3-4495-9087-691eb8945c3f.html
      

  4.   

    看看这个例子吧!
    源代码和实现说明,需要先用email注册用户!
    http://www.codeproject.com/KB/grid/NullableDatetimePicker.aspx