以这3种为例,最简单的是第三种,直接让单元格处于可编辑状态,当完成编辑后触发CellEndEdit事件,最后对输入的数据进行处理。
1 private DateTimePicker dtp = new DateTimePicker(); 2 private ComBox sellstyle = new ComBox ();//设置全局变量
1 public PlanVindicateForm() 2 { 3 InitializeComponent(); 4 dgvReaschResult.Controls.Add(dtp);//在窗体的构造函数里将datetimepicker控件加入 5 this.dgvReaschResult.Controls.Add(this.sellstyle);//combox控件 6 this.sellstyle.Visible = false;//设置是否显示 7 this.dtp.Visible = false; 8 this.dtp.Format = DateTimePickerFormat.Custom;//设置显示格式 9 this.dtp.CustomFormat = "HH:mm";