123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
-
- using DevExpress.Utils;
- using DevExpress.XtraCharts;
- using OTSIncAReportApp;
- using OTSIncAReportApp._1_UI.Control_DEVCharts;
- using OTSIncAReportApp.OTSRstMgrFunction;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGraph.Class;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace OTSIncAReportGrids
- {
- /// <summary>
- /// 颗粒平均元素成分含量表 平均元素含量表
- /// </summary>
- public partial class ElementCompositionAvgGrid : UserControl
- {
- #region 设置变量
- //设置模拟数据表
- public DataTable m_dt = new DataTable();
- //多个数据源,每个数据源拥有的列数,这里保存下来,供分组使用
- public List<int> m_list_oneresult_columncount;
- //国际化
- Language lan;
- Hashtable table;
- //测量结果
- ResultFile result = null;
- OTSIncAReportApp.frmReportApp m_ReportApp;
- //internal string condition;
- private DataGridView dgv = new DataGridView();
- frmReportConditionChoose m_condition;
- private ResultDataMgr m_DataMgr;
- int gridheight = 0;
- int gridwidth = 0;
- public bool Report { set; get; }
- /// <summary>
- /// 全部颗粒为true选择颗粒为false
- /// </summary>
- public bool ParticleRange { set; get; }
- /// <summary>
- /// 表数据
- /// </summary>
- List<DataTable> list_table_data = new List<DataTable>();
- List<Point> list_table_size = new List<Point>();
- List<Point> list_table_Point = new List<Point>();
- List<string> list_fileName = new List<string>();
- #endregion
- #region 自定义方法
- /// <summary>
- /// 绑定datagridview数据
- /// </summary>
- public void BindDataGridView(string path, int num, string filename,int sel)
- {
- List<string> colid = new List<string>() { "rowid", "pname", "area", "con" };
- List<string> colname = new List<string>() { table["str1"].ToString(), table["str4"].ToString(), table["str3"].ToString(), table["str6"].ToString() };
- OTSIncAReportApp.DataOperation.DataAccess.ParticleData particledata = new OTSIncAReportApp.DataOperation.DataAccess.ParticleData(path);
- OTSGridView gridView = new OTSGridView();
- for (int i = 0; i < colid.Count; i++)
- {
- gridView.Columns.Add(colid[i], colname[i]);
- }
- DataTable dte = particledata.GetAllElement();
- DataTable table_data = new DataTable();
- table_data.Columns.Add("TypeName");
- table_data.Columns.Add("con");
- table_data.Columns.Add("ar");
- foreach (DataRow item in dte.Rows)
- {
- DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
- iconColumn.Name = item["name"].ToString();
- iconColumn.HeaderText = item["name"].ToString();
- gridView.Columns.Add(iconColumn);
- table_data.Columns.Add(item["name"].ToString());
- }
- List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 7, 8, 9 };
- List<string> NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString() };
- string filedAndParticl = "";
- gridView.MergeColumnNames.Add(filename);
- gridView.AddSpanHeader(1, gridView.Columns.Count - 1, filename);
- DataTable dt;
- dt = particledata.GetAreaByAllIncA(filedAndParticl);
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
- {
- continue;
- }
-
- double total = Convert.ToDouble(dt.Rows[i]["ar"]);
- int add_rowindex = gridView.Rows.Add();
- gridView.Rows[add_rowindex].Cells[0].Value = add_rowindex + 1;
- gridView.Rows[add_rowindex].Cells[1].Value = dt.Rows[i]["TypeName"];
- gridView.Rows[add_rowindex].Cells[1].Style.BackColor = Color.Azure;
- gridView.Rows[add_rowindex].Cells[2].Value = Math.Round(total, 2);
- gridView.Rows[add_rowindex].Cells[2].Style.BackColor = Color.Azure;
- gridView.Rows[add_rowindex].Cells[3].Value = dt.Rows[i]["con"];
- gridView.Rows[add_rowindex].Cells[3].Style.BackColor = Color.Azure;
- DataTable dtp = particledata.GetAreaByIncA(dt.Rows[i]["TypeId"].ToString(), filedAndParticl);
- DataRow row1 = table_data.NewRow();
- row1["TypeName"] = dt.Rows[i]["TypeName"];
- row1["con"] = dt.Rows[i]["con"];
- row1["ar"] = Math.Round(total, 2);
- for (int j = 4; j < gridView.Columns.Count; j++)
- {
- int col = 0;
- foreach (DataRow dr in dtp.Rows)
- {
- if (gridView.Columns[j].Name == dr["name"].ToString())
- {
- double ar = Convert.ToDouble(dr["pc"]);
- double p = Math.Round(ar / total, 2);
- gridView.Rows[add_rowindex].Cells[j].Value = DrawFunction.GetProcessBitmap((float)p, Color.Azure);
- gridView.Rows[add_rowindex].Cells[j].Tag = p;
- row1[gridView.Columns[j].Name] = p;
- break;
- }
- col++;
- }
- if (col == dtp.Rows.Count)
- {
- gridView.Rows[add_rowindex].Cells[j].Value = DrawFunction.GetProcessBitmap(0, Color.Azure);
- gridView.Rows[add_rowindex].Cells[j].Tag = 0;
- }
- }
- table_data.Rows.Add(row1);
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
- {
- continue;
- }
- int add_rowindex = gridView.Rows.Add();
- gridView.Rows[add_rowindex].Cells[0].Value = add_rowindex + 1;
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- string name = NameList[index];
- double total = Convert.ToDouble(dt.Rows[i]["ar"]);
- gridView.Rows[add_rowindex].Cells[1].Value = dt.Rows[i]["TypeName"];
- gridView.Rows[add_rowindex].Cells[1].Style.BackColor = Color.Azure;
- gridView.Rows[add_rowindex].Cells[2].Value = Math.Round(total, 2);
- gridView.Rows[add_rowindex].Cells[2].Style.BackColor = Color.Azure;
- gridView.Rows[add_rowindex].Cells[3].Style.BackColor = Color.Azure;
- gridView.Rows[add_rowindex].Cells[3].Value = dt.Rows[i]["con"];
- DataTable dtp = particledata.GetAreaByIncA(dt.Rows[i]["TypeId"].ToString(), filedAndParticl);
-
- for (int j = 4; j < gridView.Columns.Count; j++)
- {
- int col = 0;
- foreach (DataRow dr in dtp.Rows)
- {
- if (gridView.Columns[j].Name == dr["name"].ToString())
- {
- double ar = Convert.ToDouble(dr["pc"]);
- double p = Math.Round(ar / total, 2);
- gridView.Rows[add_rowindex].Cells[j].Value = DrawFunction.GetProcessBitmap((float)p, Color.Azure);
- gridView.Rows[add_rowindex].Cells[j].Tag = p;
-
- break;
- }
- col++;
- }
- if (col == dtp.Rows.Count)
- {
- gridView.Rows[add_rowindex].Cells[j].Value = DrawFunction.GetProcessBitmap(0, Color.Azure);
- gridView.Rows[add_rowindex].Cells[j].Tag = 0;
- }
- }
- }
- list_table_data.Add(table_data);
- gridView.Name = "gridView" + num.ToString();
- dgv = gridView;
- //设置grid风格
- list_table_Point.Add(SetDataGridViewStyle(gridView));
- //SetDataGridViewStyle(gridView);
- panel1.Controls.Add(gridView);
- }
-
- /// <summary>
- /// 设置DataGridView样式
- /// </summary>
- private Point SetDataGridViewStyle(OTSGridView gridView)
- {
- //用户不能调整标题的高度
- gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- //用户不能调整 行高
- gridView.AllowUserToResizeRows = false;
- //改变行的高度;
- //gridView.RowTemplate.Height = 20;
- //点击选择整行
- gridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- //居中显示
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- gridView.DefaultCellStyle = dataGridViewCellStyle1;
- gridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- //再次重覆禁用拖动表头高度,居然有效果了
- gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- //设置grid可以复制
- gridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
- //设置每列的宽度
- gridView.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
- gridView.Columns[1].Width = 200;
- //设置序号列不排序
- gridView.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
- //设置序号列不可以设置宽度
- gridView.Columns[0].Resizable = DataGridViewTriState.False;
- gridView.AllowUserToAddRows = false;
- gridView.AllowUserToDeleteRows = false;
- gridView.AllowUserToResizeRows = false;
- gridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
- gridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- gridView.ContextMenuStrip = this.contextMenuStrip1;
- gridView.BorderStyle = 0;
- int outpos = gridwidth;
- gridView.Location = new System.Drawing.Point(gridwidth, 0);
- gridView.Margin = new System.Windows.Forms.Padding(2);
- gridView.MergeColumnHeaderBackColor = System.Drawing.SystemColors.ButtonHighlight;
- //gridView.Name = "Gview_gz";
- gridView.ReadOnly = true;
- gridView.RowHeadersVisible = false;
- gridView.RowHeadersWidth = 40;
- gridView.RowTemplate.Height = 30;
- int gridView_Width = 0;
- for (int i = 0; i < gridView.ColumnCount; i++)
- {
- gridView_Width = gridView_Width + gridView.Columns[i].Width;
- }
- gridView.Size = new System.Drawing.Size(gridView_Width+60, gridView.RowCount * 30);
- gridheight = gridheight + gridView.RowCount * 30 + 5;
- gridwidth = gridwidth + gridView.ColumnCount * 100;
- gridView.TabIndex = 0;
- gridView.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.Gview_gz_SortCompare);
- gridView.Sorted += new System.EventHandler(this.Gview_gz_Sorted);
- //先设置一下头的高度,否则会太矮不好看
- gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
- gridView.ColumnHeadersHeight = 40;
- list_table_size.Add(new Point(gridView.ColumnCount * 100 , gridView.RowCount * 30));
- return new Point(outpos, gridheight);
- }
- #endregion
- #region 初始化构造函数
- /// <summary>
- /// 元素平均含量表,构造函数
- /// </summary>
- /// <param name="in_sec">传入,委托类对象</param>
- /// <param name="in_Cotsreportprojfilemgrclr">传入,项目管理类对象</param>
- public ElementCompositionAvgGrid(OTSIncAReportApp.frmReportApp ReportApp)
- {
- m_ReportApp = ReportApp;
- result = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
- m_condition = ReportApp.m_conditionChoose;
- InitializeComponent();
- lan = new Language(this);
- table = lan.GetNameTable(this.Name);
- m_DataMgr = ReportApp.m_rstDataMgr;
- }
- private void ElementContentGrid_Load(object sender, EventArgs e)
- {
- string sou = "";
- int sel = 0;
- if (Report)
- {
- sou = m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].anotherFileName.ToString();
- if (ParticleRange)
- {
- sel = 0;
- }
- else
- {
- sel = 1;
- }
- }
- else
- {
- sou = m_condition.m_CurrentConditions[OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
- sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- }
- Report = false;
- list_fileName.Clear();
- if (sou.Contains("+"))
- {
- for (int i = 0; i < sou.Split('+').Length; i++)
- {
- ResultFile resultFile = m_ReportApp.m_rstDataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
- if (resultFile != null)
- {
- BindDataGridView(resultFile.FilePath, i, resultFile.anotherFileName, sel);
- list_fileName.Add(resultFile.anotherFileName);
- }
- }
- }
- else
- {
- for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
- {
- if (sou == m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString())
- {
- BindDataGridView(m_ReportApp.m_rstDataMgr.ResultFilesList[i].FilePath, 0, m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName, sel);
- list_fileName.Add(m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName);
- }
- }
- }
- }
- public void SetGraphicType(ReportCondition sourceGridData)
- {
- string stdId = "";
- int stdIdIndex = 0;
- //find the stdId condition
- var STDIdItm = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.STD_ID);
- if (STDIdItm != null)
- {
- stdId = STDIdItm.itemDisplayVal.ToString();
- stdIdIndex = STDIdItm.comboDownList.IndexOf(stdId);
- }
- string stdId_TYPE = "";
- int stdIdIndex_TYPE = 0;
- //find the stdId condition
- var STDIdItm_TYPE = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.GRAPHIC_TYPE);
- if (STDIdItm_TYPE != null)
- {
- stdId_TYPE = STDIdItm_TYPE.itemDisplayVal.ToString();
- stdIdIndex_TYPE = STDIdItm_TYPE.comboDownList.IndexOf(stdId);
- }
- int high = 0;
- for (int i = 0; i < list_table_Point.Count; i++)
- {
- if (high < list_table_Point[i].Y)
- {
- high = list_table_Point[i].Y;
- }
- }
- for (int i = 0; i < list_table_data.Count; i++)
- {
- Graphics(list_table_data[i], list_fileName[i], stdId_TYPE, list_table_size[i], list_table_Point[i], high);
- Graphics_Stacking(list_table_data[i], stdId, list_table_size[i], list_table_Point[i], high+ list_table_size[i].Y);
- }
- }
- private void Graphics(DataTable data, string filename, string comboBox1Text, Point a_size, Point a_Location, int location_hig)
- {
- ChartControl chartControl1 = new ChartControl();
- chartControl1.Series.Clear();
- // 假设你已经有一个 ChartControl 实例,并且已经添加了一个饼图 Series
- Series series = new Series(filename, ViewType.Bar);
- for (int a = 0; a < data.Rows.Count; a++)
- {
- string name = data.Rows[a]["TypeName"].ToString();
- double Cunt = Convert.ToDouble(data.Rows[a]["ar"]);
- series.Points.Add(new SeriesPoint(name, Cunt));
- }
- series.LabelsVisibility = DefaultBoolean.True;
- chartControl1.Series.Add(series);
- //图例的位置定义
- chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
- chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
- chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
- chartControl1.Legend.Direction = LegendDirection.TopToBottom;
- //十字准线光标
- chartControl1.CrosshairEnabled = DefaultBoolean.True;
- chartControl1.CrosshairOptions.ShowValueLine = true;
- chartControl1.CrosshairOptions.ShowArgumentLabels = true;
- DevFunctions.ChangeView2(chartControl1, comboBox1Text);
- chartControl1.Location = new Point(a_Location.X, location_hig);
- chartControl1.Size = new Size(a_size.X, a_size.Y);
- // 获取图表的坐标系(通常为 XYDiagram)
- XYDiagram diagram = chartControl1.Diagram as XYDiagram;
- if (diagram != null)
- {
- // 设置横坐标(X轴)名称
- diagram.AxisX.Title.Text = "种类";
- diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.True; // 确保标题可见
- // 设置纵坐标(Y轴)名称
- diagram.AxisY.Title.Text = "面积";
- diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True; // 确保标题可见
- }
- panel1.Controls.Add(chartControl1);
- }
- /// <summary>
- /// chart图创建
- /// </summary>
- /// <param name="dt"></param>
- /// <param name="stdId"></param>
- private void Graphics_Stacking(DataTable dt, string stdId, Point a_size, Point a_Location, int location_hig)
- {
- ChartControl chartControl1 = new ChartControl();
- chartControl1.Series.Clear();
- chartControl1.Size = new Size(a_size.X, a_size.Y);
- chartControl1.Location = new Point(a_Location.X, location_hig);
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("name");
- dataTable.Columns.Add("size");
- if (stdId != "All")
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["TypeName"].ToString() == stdId)
- {
- for (int a = 3; a < dt.Columns.Count; a++)
- {
- DataRow dr = dataTable.NewRow();
- dr["name"] = dt.Columns[a].ColumnName;
- if (dt.Rows[i][a].ToString() == "")
- {
- dr["size"] = 0;
- }
- else
- {
- dr["size"] = Convert.ToDouble(dt.Rows[i][a]);
- }
-
- dataTable.Rows.Add(dr);
- }
- }
- }
- }
- if (stdId == "All")
- {
- List<Series> seriesList = new List<Series>();
- DataTable data = new DataTable();
- data.Columns.Add("name");
- data.Columns.Add("range");
- data.Columns.Add("num");
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- for (int a = 3; a < dt.Columns.Count; a++)
- {
- DataRow dr = data.NewRow();
- dr["name"] = dt.Rows[i]["TypeName"].ToString();
- dr["range"] = dt.Columns[a].ColumnName;
- if (dt.Rows[i][a].ToString() == "")
- {
- dr["num"] = 0;
- }
- else
- {
- dr["num"] = dt.Rows[i][a].ToString();
- }
-
- data.Rows.Add(dr);
- }
- }
- foreach (DataRow dr in data.DefaultView.ToTable(true, "name").Rows)
- {
- Series s = new Series(dr["name"].ToString(), ViewType.StackedBar)
- {
- LegendTextPattern = dr["name"].ToString(),
- ArgumentScaleType = ScaleType.Qualitative,
- };
- foreach (DataRow drl in data.Select("name='" + dr["name"].ToString() + "'"))
- s.Points.Add(new SeriesPoint(drl["range"].ToString(), double.Parse(drl["num"].ToString())));
- s.LabelsVisibility = DefaultBoolean.False;
- seriesList.Add(s);
- }
- foreach (Series sr in seriesList.ToArray())
- chartControl1.Series.Add(sr);
- }
- else
- {
- // 假设你已经有一个 ChartControl 实例,并且已经添加了一个饼图 Series
- Series series = new Series(stdId, ViewType.Bar);
- for (int a = 0; a < dataTable.Rows.Count; a++)
- {
- string name = dataTable.Rows[a]["name"].ToString();
- double Cunt = Convert.ToDouble(dataTable.Rows[a]["size"]);
- series.Points.Add(new SeriesPoint(name, Cunt));
- }
- series.LabelsVisibility = DefaultBoolean.True;
- chartControl1.Series.Add(series);
- }
- ((XYDiagram)chartControl1.Diagram).AxisY.Title.Text = "";
- ((XYDiagram)chartControl1.Diagram).AxisX.Title.Text = "";
- ((XYDiagram)chartControl1.Diagram).AxisY.Title.Visibility = DefaultBoolean.True;
- ((XYDiagram)chartControl1.Diagram).AxisX.Title.Visibility = DefaultBoolean.True;
- ((XYDiagram)chartControl1.Diagram).AxisY.Title.Font = new Font("Tahoma", 9);
- ((XYDiagram)chartControl1.Diagram).AxisX.Title.Font = new Font("Tahoma", 9);
- ((XYDiagram)chartControl1.Diagram).AxisY.Title.Alignment = System.Drawing.StringAlignment.Far;
- ((XYDiagram)chartControl1.Diagram).AxisX.Title.Alignment = System.Drawing.StringAlignment.Far;
- //图例的位置定义
- chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
- chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
- chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
- chartControl1.Legend.Direction = LegendDirection.TopToBottom;
- //十字准线光标
- chartControl1.CrosshairEnabled = DefaultBoolean.True;
- chartControl1.CrosshairOptions.ShowValueLine = true;
- chartControl1.CrosshairOptions.ShowArgumentLabels = true;
- panel1.Controls.Add(chartControl1);
- }
- #endregion
- #region 相关事件
- private void ToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- //复制整个表
- CopyAll();
- }
- private void ToolStripMenuItem2_Click(object sender, EventArgs e)
- {
- //复制选择区域
- CopySelected();
- }
- /// <summary>
- /// 复制选择区域
- /// </summary>
- public void CopySelected()
- {
- //复制选择区域
- object oo = Gview_gz.GetClipboardContent();
- Clipboard.SetDataObject(Gview_gz.GetClipboardContent());
- }
- /// <summary>
- /// 复制所有
- /// </summary>
- public void CopyAll()
- {
- Gview_gz.SelectAll();
- Clipboard.SetDataObject(Gview_gz.GetClipboardContent());
- }
- private void ToolStripMenuItem3_Click(object sender, EventArgs e)
- {
- //恢复至初始状态
- Gview_gz.Rows.Clear();
- Gview_gz.Columns.Clear();
- //BindDataGridView();
- //SetDataGridViewStyle();
- }
- private void Gview_gz_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
- {
- //排序中
- if (this.Gview_gz.Rows[e.RowIndex1].Tag != null && this.Gview_gz.Rows[e.RowIndex1].Tag.ToString() == "统计行")
- {
- //ROW1>ROW2
- e.SortResult = 1;
- if (this.Gview_gz.SortOrder == SortOrder.Descending)
- e.SortResult = -1;
- e.Handled = true;
- return;
- }
- if (this.Gview_gz.Rows[e.RowIndex2].Tag != null && this.Gview_gz.Rows[e.RowIndex2].Tag.ToString() == "统计行")
- {
- //ROW1<ROW2
- e.SortResult = -1;
- if (this.Gview_gz.SortOrder == SortOrder.Descending)
- e.SortResult = 1;
- e.Handled = true;
- return;
- }
- }
- private void Gview_gz_Sorted(object sender, EventArgs e)
- {
- //排序完成,重新设置序号
- for (int i = 0; i < Gview_gz.Rows.Count; i++)
- {
- if (Gview_gz.Rows[i].Tag != null && this.Gview_gz.Rows[i].Tag.ToString() == "统计行")
- { }
- else
- {
- Gview_gz.Rows[i].Cells[0].Value = i.ToString();
- }
- }
- }
- #endregion
- #region 获取向导出模块提供的DataTable和GridView对象
- /// <summary>
- /// 获取到该模块输出后形成的DataTable,和GridView
- /// </summary>
- /// <param name="out_dt"></param>
- /// <param name="out_dg"></param>
- public void GetDataTableAndGridView(out DataTable out_dt, out DataGridView out_dg)
- {
- out_dt = m_dt;
- //out_dt = (this.Gview_gz.DataSource as DataTable);
- //out_dg = this.Gview_gz;
- out_dg = dgv;
- }
- #endregion
- }
- }
|