/// <summary> /// 单元格开始编辑时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void report1_CellBeginEdit(object sender, Gscr.CellCancelEventArgs e) { if (this.report1.Rows[e.Cell.RowIndex].Band == Gscr.Band.Detail && e.Cell.ColumnIndex == 4) { //编辑的是<部门>列,对<部门>列的编辑控件ReportFindEditer进行配置 if (report1.EditingControl != null && report1.EditingControl is Gscr.Editer.ReportFindEditer) { //获取<部门>列的编辑控件 Gscr.Editer.ReportFindEditer editer = ((Gscr.Editer.ReportFindEditer)report1.EditingControl); //ReportFindEditer增量查询时,对应的列索引,本例选择的是<Code>,索引为0 editer.FindColumnIndex = 0; //ReportFindEditer要选择的值所在的索引,本例选择的是<Code>,索引为0 editer.ValueColumnIndex = 0; //配置ReportFindEditer报表的数据源 Gscr.Report rpt = editer.PopupControl.report1; ////把report2的整个报表包括数据复制给ReportFindEditer报表 report2.CopyReport(rpt, false); ////你也可以如下写 ////自动创建列 //rpt.AutoGenerateColumns = true; ////设置数据源 //rpt.DataSource = dtDepartment; ////绑定数据源 //rpt.DataBind(); } } if (this.report1.Rows[e.Cell.RowIndex].Band == Gscr.Band.Detail && e.Cell.ColumnIndex == 7) { //编辑的是<应发款>列,对<应发款>列的编辑控件ReportNumberTextBoxEditer进行配置 if (report1.EditingControl != null && report1.EditingControl is Gscr.Editer.ReportNumberTextBoxEditer) { //获取<应发款>列的编辑控件 Gscr.Editer.ReportNumberTextBoxEditer editer = ((Gscr.Editer.ReportNumberTextBoxEditer)report1.EditingControl); //设置为输入四位小数 editer.NumberDecimalDigits = 4; editer.SelectAll(); } } if (this.report1.Rows[e.Cell.RowIndex].Band == Gscr.Band.Detail && report1.Columns[e.Cell.ColumnIndex].ColumnName == "出生日期") { //编辑的是<出生日期>列,对<出生日期>列的编辑控件ReportDateTimePickerEditer进行配置 if (report1.EditingControl != null && report1.EditingControl is Gscr.Editer.ReportDateTimePickerEditer) { //获取<出生日期>列的编辑控件 Gscr.Editer.ReportDateTimePickerEditer editer = ((Gscr.Editer.ReportDateTimePickerEditer)report1.EditingControl); editer.FormatCustom = "yyyy-MM-dd hh:mm:ss"; editer.Format = Gscr.Controls.DateTimePickerFormat.LongDateTime; } } }
/// <summary> /// 单元格开始编辑时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void report1_CellBeginEdit(object sender, Gscr.CellCancelEventArgs e) { if (this.report1.Rows[e.Cell.RowIndex].Band == Gscr.Band.Detail && e.Cell.ColumnIndex == 2) { //编辑的是<选修课>列,对<选修课>列的编辑控件ReportCheckedListBoxEditer进行配置 if (report1.EditingControl != null && report1.EditingControl is Example.ReportCheckedListBoxEditer) { Example.ReportCheckedListBoxEditer editer = ((Example.ReportCheckedListBoxEditer)report1.EditingControl); //增加项 editer.Items.Add("电子信息"); editer.Items.Add("会计"); editer.Items.Add("计算机"); //初始化ReportCheckedListBoxEditer值,即把单元格的值赋给ReportCheckedListBoxEditer控件 editer.InitEditControlValue(e.Cell); } } }