/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.multiEditorRowProperties1 = new DevExpress.XtraVerticalGrid.Rows.MultiEditorRowProperties(); this.multiEditorRowProperties2 = new DevExpress.XtraVerticalGrid.Rows.MultiEditorRowProperties(); this.vGridControl1 = new DevExpress.XtraVerticalGrid.VGridControl(); this.customersBindingSource = new System.Windows.Forms.BindingSource(this.components); this.nwindDataSet = new WindowsApplication409.nwindDataSet(); this.rowAddress = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowCity = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowCompanyName = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowContactTitle = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowContactName = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowCountry = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowFax = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.multiEditorRow1 = new DevExpress.XtraVerticalGrid.Rows.MultiEditorRow(); this.rowCustomerID = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowPostalCode = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.rowRegion = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); this.customersTableAdapter = new WindowsApplication409.nwindDataSetTableAdapters.CustomersTableAdapter(); ((System.ComponentModel.ISupportInitialize)(this.vGridControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.customersBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nwindDataSet)).BeginInit(); this.SuspendLayout(); // // multiEditorRowProperties1 // this.multiEditorRowProperties1.Caption = "Company"; this.multiEditorRowProperties1.FieldName = "CompanyName"; // // multiEditorRowProperties2 // this.multiEditorRowProperties2.Caption = "Phone"; this.multiEditorRowProperties2.FieldName = "Phone"; // // vGridControl1 // this.vGridControl1.DataSource = this.customersBindingSource; this.vGridControl1.LayoutStyle = DevExpress.XtraVerticalGrid.LayoutViewStyle.SingleRecordView; this.vGridControl1.Location = new System.Drawing.Point(2, 12); this.vGridControl1.Name = "vGridControl1"; this.vGridControl1.RecordWidth = 127; this.vGridControl1.RowHeaderWidth = 73; this.vGridControl1.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.rowAddress, this.rowContactTitle, this.rowPostalCode }); this.vGridControl1.ShowButtonMode = DevExpress.XtraVerticalGrid.ShowButtonModeEnum.ShowAlways; this.vGridControl1.Size = new System.Drawing.Size(448, 400); this.vGridControl1.TabIndex = 0; // // customersBindingSource // this.customersBindingSource.DataMember = "Customers"; this.customersBindingSource.DataSource = this.nwindDataSet; // // nwindDataSet // this.nwindDataSet.DataSetName = "nwindDataSet"; this.nwindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // rowAddress // this.rowAddress.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.rowCity }); this.rowAddress.Height = 16; this.rowAddress.Name = "rowAddress"; this.rowAddress.Properties.Caption = "Address"; this.rowAddress.Properties.FieldName = "Address"; // // rowCity // this.rowCity.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.rowCompanyName }); this.rowCity.Name = "rowCity"; this.rowCity.Properties.Caption = "City"; this.rowCity.Properties.FieldName = "City"; // // rowCompanyName // this.rowCompanyName.Name = "rowCompanyName"; this.rowCompanyName.Properties.Caption = "CompanyName"; this.rowCompanyName.Properties.FieldName = "CompanyName"; // // rowContactTitle // this.rowContactTitle.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.rowContactName, this.rowCountry, this.rowCustomerID }); this.rowContactTitle.Name = "rowContactTitle"; this.rowContactTitle.Properties.Caption = "ContactTitle"; this.rowContactTitle.Properties.FieldName = "ContactTitle"; // // rowContactName // this.rowContactName.Name = "rowContactName"; this.rowContactName.Properties.Caption = "ContactName"; this.rowContactName.Properties.FieldName = "ContactName"; // // rowCountry // this.rowCountry.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.rowFax }); this.rowCountry.Name = "rowCountry"; this.rowCountry.Properties.Caption = "Country"; this.rowCountry.Properties.FieldName = "Country"; // // rowFax // this.rowFax.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.multiEditorRow1 }); this.rowFax.Name = "rowFax"; this.rowFax.Properties.Caption = "Fax"; this.rowFax.Properties.FieldName = "Fax"; // // multiEditorRow1 // this.multiEditorRow1.Name = "multiEditorRow1"; this.multiEditorRow1.PropertiesCollection.AddRange(new DevExpress.XtraVerticalGrid.Rows.MultiEditorRowProperties[] { this.multiEditorRowProperties1, this.multiEditorRowProperties2 }); // // rowCustomerID // this.rowCustomerID.Name = "rowCustomerID"; this.rowCustomerID.Properties.Caption = "CustomerID"; this.rowCustomerID.Properties.FieldName = "CustomerID"; // // rowPostalCode // this.rowPostalCode.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.rowRegion }); this.rowPostalCode.Name = "rowPostalCode"; this.rowPostalCode.Properties.Caption = "PostalCode"; this.rowPostalCode.Properties.FieldName = "PostalCode"; // // rowRegion // this.rowRegion.Name = "rowRegion"; this.rowRegion.Properties.Caption = "Region"; this.rowRegion.Properties.FieldName = "Region"; // // simpleButton1 // this.simpleButton1.Location = new System.Drawing.Point(160, 424); this.simpleButton1.Name = "simpleButton1"; this.simpleButton1.Size = new System.Drawing.Size(75, 23); this.simpleButton1.TabIndex = 1; this.simpleButton1.Text = "FindRow"; this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click); // // customersTableAdapter // this.customersTableAdapter.ClearBeforeFill = true; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(515, 462); this.Controls.Add(this.simpleButton1); this.Controls.Add(this.vGridControl1); this.Name = "Form1"; this.Text = "How to obtain a row object by FieldName in the XtraVerticalGrid"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.vGridControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.customersBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nwindDataSet)).EndInit(); this.ResumeLayout(false); }
/// <summary> /// 单击VGridview生成图表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StatisticsAndChart_vGridControl_MouseClick(object sender, MouseEventArgs e) { DevExpress.XtraVerticalGrid.VGridControl gridcontrol = new DevExpress.XtraVerticalGrid.VGridControl(); gridcontrol = sender as DevExpress.XtraVerticalGrid.VGridControl; VGridHitInfo info = gridcontrol.CalcHitInfo(new Point(e.X, e.Y)); //当左键单击HeaderCell时 if (info.HitInfoType == HitInfoTypeEnum.HeaderCell && info.Row.HasChildren && e.Button == MouseButtons.Left && info.Row.Properties.Caption.IndexOf('*') != 0) { BaseRow baserow = gridcontrol.FocusedRow; CategoryRow gr = baserow as CategoryRow; //根据tag加载列数据 if (gr != null && gr.Tag != null) { string[] data = null; //判断字段类型是否为数值型 if (gridview.Columns[gr.Properties.Caption].ColumnType.IsValueType) { //读取tag中的数据至数组 double[] doubledata = gr.Tag as double[]; List <double> doublelist = doubledata.ToList(); //计算唯一值及唯一值个数 List <double> d_uniquevalue = doubledata.Distinct().ToList(); int d_uniquecount = d_uniquevalue.Count; //当唯一值个数大于30时,执行分组处理 if (d_uniquecount > 30) { //计算分组间距 double interval = (d_uniquevalue.Max() - d_uniquevalue.Min()) / 25; //计算图表中加入点的值 List <string> chart_uniquevalue = new List <string>(); for (int n = 0; n < 26; n++) { if (n == 25) { chart_uniquevalue.Add((interval * n).ToString("0.0") + "-" + d_uniquevalue.Max().ToString("0.0")); } else { chart_uniquevalue.Add((interval * n).ToString("0.0") + "-" + (interval * (n + 1)).ToString("0.0")); } } double max = d_uniquevalue.Max(); //chart_uniquevalue.Add((d_uniquevalue.Max()).ToString()); //声明26个list类型的数组 List <double>[] findlist = new List <double> [26]; for (int n = 0; n < 26; n++) { findlist[n] = new List <double>(); } //根据分组间距,将所有数据存放到对应的26个list中 for (int n = 0; n < doublelist.Count; n++) { findlist[(int)(doublelist[n] / interval)].Add(doublelist[n]); } //完成分组 //清除图表数据,重新载入数据 for (int i = 0; i < StatisticsChart_chart1.Series.Count; i++) { StatisticsChart_chart1.Series.RemoveAt(i); } //创建图表 Series series = new Series(gr.Properties.Caption + "_Count", ViewType.Bar); for (int n = 0; n < 26; n++) { series.Points.Add(new SeriesPoint(chart_uniquevalue[n].ToString(), findlist[n].Count)); } StatisticsChart_chart1.Series.Add(series); } else { data = new string[gridview.RowCount]; for (int i = 0; i < doubledata.Count(); i++) { data[i] = doubledata[i].ToString(); } } } else { data = new string[gridview.RowCount]; data = gr.Tag as string[]; } if (data != null) { List <string> datalist = data.ToList(); //获取唯一值 List <string> UniqueValue = data.Distinct().ToList(); int uniquecount = UniqueValue.Count; if ((uniquecount <= 300) || (uniquecount > 300 && (MessageBox.Show("分类数较多,是否继续?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes))) { //清除图表数据,重新载入数据 for (int i = 0; i < StatisticsChart_chart1.Series.Count; i++) { StatisticsChart_chart1.Series.RemoveAt(i); } //创建图表 Series series1 = new Series("", ViewType.Bar); for (int i = 0; i < uniquecount; i++) { series1.Points.Add(new SeriesPoint(UniqueValue[i], (datalist.FindAll(value => value.Contains(UniqueValue[i]))).Count)); } StatisticsChart_chart1.Series.Add(series1); } } //生成X坐标轴名称 XYDiagram diagram = (XYDiagram)StatisticsChart_chart1.Diagram; diagram.AxisX.Title.Visible = true; diagram.AxisX.Title.Alignment = StringAlignment.Center; diagram.AxisX.Title.Text = info.Row.Properties.Caption; //生成Y坐标轴名称 diagram.AxisY.Title.Visible = true; diagram.AxisY.Title.Alignment = StringAlignment.Center; diagram.AxisY.Title.Text = "Count"; } } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.vGridControl1 = new DevExpress.XtraVerticalGrid.VGridControl(); this.categoryRow1 = new DevExpress.XtraVerticalGrid.Rows.CategoryRow(); this.editorRow1 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.editorRow2 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.categoryRow2 = new DevExpress.XtraVerticalGrid.Rows.CategoryRow(); this.editorRow3 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.editorRow4 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.editorRow5 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); ((System.ComponentModel.ISupportInitialize)(this.vGridControl1)).BeginInit(); this.SuspendLayout(); // // vGridControl1 // this.vGridControl1.AllowDrop = true; this.vGridControl1.OptionsBehavior.Editable = true; this.vGridControl1.OptionsBehavior.AutoSelectAllInEditor = true; this.vGridControl1.OptionsBehavior.SmartExpand = true; this.vGridControl1.OptionsBehavior.ResizeRowHeaders = true; this.vGridControl1.OptionsBehavior.ResizeHeaderPanel = true; this.vGridControl1.OptionsBehavior.ResizeRowValues = true; this.vGridControl1.OptionsBehavior.DragRowHeaders = true; this.vGridControl1.OptionsBehavior.UseTabKey = true; this.vGridControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.vGridControl1.Location = new System.Drawing.Point(0, 0); this.vGridControl1.Name = "vGridControl1"; this.vGridControl1.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.categoryRow1, this.categoryRow2 }); this.categoryRow1.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.editorRow1, this.editorRow2 }); this.categoryRow2.ChildRows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.editorRow3, this.editorRow4, this.editorRow5 }); this.vGridControl1.Size = new System.Drawing.Size(240, 166); this.vGridControl1.TabIndex = 2; this.vGridControl1.Text = "vGridControl1"; this.vGridControl1.EndDragRow += new DevExpress.XtraVerticalGrid.Events.EndDragRowEventHandler(this.vGridControl1_EndDragRow); this.vGridControl1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.vGridControl1_MouseMove); this.vGridControl1.StartDragRow += new DevExpress.XtraVerticalGrid.Events.StartDragRowEventHandler(this.vGridControl1_StartDragRow); this.vGridControl1.CustomDrawRowHeaderCell += new DevExpress.XtraVerticalGrid.Events.CustomDrawRowHeaderCellEventHandler(this.vGridControl1_CustomDrawRowHeaderCell); // // categoryRow1 // this.categoryRow1.Name = "categoryRow1"; // // editorRow1 // this.editorRow1.Name = "editorRow1"; this.editorRow1.Properties.Caption = "1"; // // editorRow2 // this.editorRow2.Name = "editorRow2"; this.editorRow2.Properties.Caption = "2"; // // categoryRow2 // this.categoryRow2.Name = "categoryRow2"; // // editorRow3 // this.editorRow3.Name = "editorRow3"; this.editorRow3.Properties.Caption = "3"; // // editorRow4 // this.editorRow4.Name = "editorRow4"; this.editorRow4.Properties.Caption = "4"; // // editorRow5 // this.editorRow5.Name = "editorRow5"; this.editorRow5.Properties.Caption = "5"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(240, 166); this.Controls.Add(this.vGridControl1); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.vGridControl1)).EndInit(); this.ResumeLayout(false); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.textEdit1 = new DevExpress.XtraEditors.TextEdit(); this.vGridControl1 = new DevExpress.XtraVerticalGrid.VGridControl(); this.editorRow1 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.editorRow2 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.editorRow3 = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); this.textEdit2 = new DevExpress.XtraEditors.TextEdit(); this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.vGridControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).BeginInit(); this.SuspendLayout(); // // textEdit1 // this.textEdit1.EditValue = "textEdit1"; this.textEdit1.Location = new System.Drawing.Point(13, 7); this.textEdit1.Name = "textEdit1"; this.textEdit1.Size = new System.Drawing.Size(94, 20); this.textEdit1.TabIndex = 0; // // vGridControl1 // this.vGridControl1.Location = new System.Drawing.Point(13, 35); this.vGridControl1.Name = "vGridControl1"; this.vGridControl1.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { this.editorRow1, this.editorRow2, this.editorRow3 }); this.vGridControl1.Size = new System.Drawing.Size(207, 208); this.vGridControl1.TabIndex = 1; this.vGridControl1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.vGridControl1_KeyDown); this.vGridControl1.EditorKeyDown += new System.Windows.Forms.KeyEventHandler(this.vGridControl1_KeyDown); // // editorRow1 // this.editorRow1.Name = "editorRow1"; this.editorRow1.Properties.Caption = "Row 1"; this.editorRow1.Properties.Value = "Value 1"; // // editorRow2 // this.editorRow2.Name = "editorRow2"; this.editorRow2.Properties.Caption = "Row 2"; this.editorRow2.Properties.Value = "Value 2"; // // editorRow3 // this.editorRow3.Name = "editorRow3"; this.editorRow3.Properties.Caption = "Row 3"; this.editorRow3.Properties.Value = "Value 3"; // // textEdit2 // this.textEdit2.EditValue = "textEdit2"; this.textEdit2.Location = new System.Drawing.Point(13, 250); this.textEdit2.Name = "textEdit2"; this.textEdit2.Size = new System.Drawing.Size(94, 20); this.textEdit2.TabIndex = 2; // // simpleButton1 // this.simpleButton1.Location = new System.Drawing.Point(120, 250); this.simpleButton1.Name = "simpleButton1"; this.simpleButton1.Size = new System.Drawing.Size(93, 20); this.simpleButton1.TabIndex = 3; this.simpleButton1.Text = "Customize..."; this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(280, 325); this.Controls.Add(this.simpleButton1); this.Controls.Add(this.textEdit2); this.Controls.Add(this.vGridControl1); this.Controls.Add(this.textEdit1); this.Name = "Form1"; this.Text = "How to move focus from the last row to the first row when the Tab key is pressed"; ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.vGridControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).EndInit(); this.ResumeLayout(false); }
public static void deletefitphase(DevExpress.XtraVerticalGrid.VGridControl vGridControl1, CategoryRow rowMain, int removeid) { rowMain.ChildRows.RemoveAt(removeid); }
public static void addfitphase(DevExpress.XtraVerticalGrid.VGridControl vGridControl1, CategoryRow rowMain, int phasei, string AprsType, DateTime BeginDate, DateTime EndDate, double QiValue, double DiValue, double niValue) { CategoryRow fitphase = new CategoryRow("拟合阶段" + phasei.ToString()); rowMain.ChildRows.Add(fitphase); // creating and modifying the Category row EditorRow rowCategory2 = new EditorRow("拟合模型"); rowCategory2.Properties.Caption = "拟合模型"; // adding the Category row to the Model row's child collection fitphase.ChildRows.Add(rowCategory2); RepositoryItemComboBox riCombo = new RepositoryItemComboBox(); riCombo.Items.AddRange(new string[] { "指数递减", "双曲递减", "调和递减" }); //Add a repository item to the repository items of grid control vGridControl1.RepositoryItems.Add(riCombo); //Now you can define the repository item as an inplace editor of columns // populating the combo box with data rowCategory2.Properties.Value = "指数递减"; rowCategory2.Properties.RowEdit = riCombo; // vGridControl1.SetCellValue(rowCategory2, vGridControl1.FocusedRecord, "customText"); // creating and modifying the Category row EditorRow startdate = new EditorRow("开始时间"); startdate.Properties.Caption = "开始时间"; // adding the Category row to the Model row's child collection RepositoryItemDateEdit ridate = vGridControl1.RepositoryItems.Add("DateEdit") as RepositoryItemDateEdit; fitphase.ChildRows.Add(startdate); startdate.Properties.Value = BeginDate; vGridControl1.RepositoryItems.Add(ridate); //Now you can define the repository item as an inplace editor of columns // populating the combo box with data startdate.Properties.RowEdit = ridate; EditorRow enddate = new EditorRow("结束时间"); enddate.Properties.Caption = "结束时间"; // adding the Category row to the Model row's child collection fitphase.ChildRows.Add(enddate); enddate.Properties.Value = 232; enddate.Properties.Value = EndDate; enddate.Properties.RowEdit = ridate; DateTime discount = Convert.ToDateTime(enddate.Properties.Value); //Create a repository item corresponding to a combo box editor to the persistent repository EditorRow Qi = new EditorRow("初始递减产量"); Qi.Properties.Caption = "初始递减产量"; // adding the Category row to the Model row's child collection fitphase.ChildRows.Add(Qi); Qi.Properties.Value = string.Format("{0} Km", QiValue); //double discoun2t = Convert.ToDouble(Qi.Properties.Value); //double dd = discoun2t; //Qi.Properties.ShowUnboundExpressionMenu = true; EditorRow di = new EditorRow("初始递减率"); di.Properties.Caption = "初始递减率"; // adding the Category row to the Model row's child collection fitphase.ChildRows.Add(di); di.Properties.Value = DiValue; EditorRow ni = new EditorRow("递减指数"); ni.Properties.Caption = "递减指数"; // adding the Category row to the Model row's child collection fitphase.ChildRows.Add(ni); ni.Properties.Value = niValue; RepositoryItemButtonEdit rib = new RepositoryItemButtonEdit();//Button按钮 //rib.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;//隐藏文字 rib.Buttons[0].Caption = "Km"; rib.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph;//按钮样式 ni.Properties.RowEdit = rib; }