Пример #1
0
 //插入列
 private void InsertCol(object sender, EventArgs e)
 {
     using (ColumnNameInputDlg dlg = new ColumnNameInputDlg("", "", report.OriginalData.Columns))
     {
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             if (DesignHelper.ContainColumnName(report, dlg.IColumnText, ""))
             {
                 Function.Alert("已经存在当前内部名称,插入列失败", "提示");
                 return;
             }
             ReportColumn newColumn = new ReportColumn(dlg.IColumnText);
             newColumn.Attibutes.NameZh_cn = dlg.EColumnText;
             int columnIndex = sheet.ActiveColumnIndex;
             sheet.Columns.Add(columnIndex, 1);
             sheet.ColumnHeader.Cells[0, columnIndex].Text = newColumn.Attibutes.NameZh_cn;
             sheet.ColumnHeader.Cells[1, columnIndex].Text = newColumn.ColumnName;
             newColumn.ColumnWidth = Convert.ToInt32(sheet.Columns[columnIndex].Width);
             report.Columns.Insert(columnIndex, newColumn);
             btn_save.Enabled = true;
         }
     }
 }
Пример #2
0
        private void SetColName(object sender, EventArgs e)
        {
            int columnIndex = sheet.ActiveColumnIndex;

            using (ColumnNameInputDlg dlg = new ColumnNameInputDlg(sheet.ColumnHeader.Cells[0, columnIndex].Text, sheet.ColumnHeader.Cells[1, columnIndex].Text, report.OriginalData.Columns))
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (DesignHelper.ContainColumnName(report, dlg.IColumnText, sheet.ColumnHeader.Cells[1, columnIndex].Text))
                    {
                        Function.Alert("列中已经存在了当前内部名称,修改失败", "提示");
                        return;
                    }
                    sheet.ColumnHeader.Cells[0, columnIndex].Text = dlg.EColumnText;
                    sheet.ColumnHeader.Cells[1, columnIndex].Text = dlg.IColumnText;
                    report.Columns.SetColumnName(report.Columns[columnIndex], dlg.IColumnText);
                    //report.Columns[columnIndex].ColumnName =

                    report.Columns[columnIndex].Attibutes.NameZh_cn = dlg.EColumnText;
                    sheet.Columns[columnIndex].Tag = dlg.IColumnText;
                    btn_save.Enabled = true;
                }
            }
        }