/// <summary> /// Handles the default grid initialization /// </summary> private void InitializeGrid() { GridPanel panel = superGridControl1.PrimaryGrid; // In this example we have two different Editor // and Render controls for the "NumericUpDown" column GridColumn column = panel.Columns["NumericUpDown"]; // Set the min and max range for the EditControl GridNumericUpDownEditControl nc = (GridNumericUpDownEditControl)column.EditControl; nc.Minimum = -10000; nc.Maximum = 10000; nc.DecimalPlaces = 3; // Set the column's RenderType to be a GridDoubleInputEditControl // so that we can set a specialized display format for it column.RenderType = typeof(GridDoubleInputEditControl); GridDoubleInputEditControl rc = (GridDoubleInputEditControl)column.RenderControl; rc.DisplayFormat = "#,###.###;(#,###.###);**Zero**"; // Now lets add 100 rows for the user to play around with for (int i = 0; i < 100; i++) { GridRow row = GetNewRow(); // Add a few random nested sub-rows, and then finally // add the newly created row to the grid panel AddRandomSubRows(row); panel.Rows.Add(row); } }
private void InitializeGrid() { GridPanel panel = sgcStock.PrimaryGrid; panel.FrozenColumnCount = 4; GridColumnCollection columns = panel.Columns; List <SYS_DictItemLineResult> itemLineList = dictLineLogic.GetListByCode(new SYS_DictItemLineParam { ItemCodes = new string[] { "Currency" } }); foreach (GridColumn gridColumn in columns) { GridNumericUpDownEditControl nc = null; GridDoubleInputEditControl rc = null; switch (gridColumn.Name) { case "colCurrency": dictLineLogic.BindComboBox(gridColumn.EditControl, "Currency", itemLineList); dictLineLogic.BindComboBox(gridColumn.RenderControl, "Currency", itemLineList); //gridColumn.RenderType = typeof(GridComboBoxExEditControl); break; case "colModel": case "colItemCode": case "colTItemCode": case "colBrand": case "colBatch": case "colPackage": case "colWarehouse": case "colInvQty": case "colBookedQty": case "colUsableQty": case "colInBatchNo": case "colLocation": case "colQuality": case "colMPQ": case "colMarkCode": case "colDescription": case "colRemark": case "colInvType": case "colUnit": case "colCreatedTime": gridColumn.ReadOnly = true; break; case "colBuyPriceRMB": case "colBuyPrice": case "colBuyAveragePrice": nc = (GridNumericUpDownEditControl)gridColumn.EditControl; nc.Minimum = 0; nc.Maximum = 10000; nc.DecimalPlaces = 5; gridColumn.RenderType = typeof(GridDoubleInputEditControl); rc = (GridDoubleInputEditControl)gridColumn.RenderControl; rc.DisplayFormat = "#,###.###;(#,###.###);"; gridColumn.ReadOnly = true; break; case "colFollowPrice": case "colSalePrice": nc = (GridNumericUpDownEditControl)gridColumn.EditControl; nc.Minimum = 0; nc.Maximum = 10000; nc.DecimalPlaces = 5; gridColumn.RenderType = typeof(GridDoubleInputEditControl); rc = (GridDoubleInputEditControl)gridColumn.RenderControl; rc.DisplayFormat = "#,###.###;(#,###.###);"; rc.DisplayFormat = "F3"; break; } } }