示例#1
0
        private void ConstructDatagridview(eZDataGridView eZDgv)
        {
            // 设置表格信息
            eZDgv.KeyDelete      = true;
            eZDgv.ManipulateRows = true;
            eZDgv.ShowRowNumber  = true;
            eZDgv.SupportPaste   = true;
            //
            eZDgv.AllowUserToAddRows = true;
            //
            Column_X.ValueType        = typeof(double);
            Column_X.DataPropertyName = "X";

            //
            Column_Y.ValueType        = typeof(double);
            Column_Y.DataPropertyName = "Y";
            //

            //
            _points = new BindingList <LocationPoint>
            {
                AllowNew = true
            };
            _points.AddingNew += PointsOnAddingNew;

            // 事件关联
            eZDgv.DataError += EZDgvOnDataError;
            eZDgv.DataSource = _points;
        }
示例#2
0
        private void DgvSetup_SoilRockRange(eZDataGridView eZdgv, IList <SoilRockRange> datasource)
        {
            eZdgv.AutoGenerateColumns = false;
            // eZdgv.EditMode = DataGridViewEditMode.EditOnEnter;
            //
            eZdgv.DataSource = datasource;
            //
            eZdgv.ManipulateRows = true;
            eZdgv.ShowRowNumber  = true;
            eZdgv.SupportPaste   = true;
            // -------------------------
            var column = new DataGridViewTextBoxColumn();

            column.DataPropertyName = "StartStation";
            column.Name             = "起始桩号";
            eZdgv.Columns.Add(column);
            //
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "EndStation";
            column.Name             = "末尾桩号";
            eZdgv.Columns.Add(column);

            // -------------------------
            var combo = new DataGridViewComboBoxColumn();

            combo.DataSource       = Enum.GetValues(typeof(SubgradeType));
            combo.DataPropertyName = "Type";
            combo.Name             = "类型";
            combo.Width            = 100;
            eZdgv.Columns.Add(combo);
            // 如果要设置对应单元格的值为某枚举项:combo.Item(combo.Index,行号).Value = Gender.Male;

            // -------------------------
            combo                  = new DataGridViewComboBoxColumn();
            combo.DataSource       = Enum.GetValues(typeof(SoilRockRange.Distribution));
            combo.DataPropertyName = "SideDistribution";
            combo.Name             = "分布";
            combo.Width            = 100;
            eZdgv.Columns.Add(combo);
            // 如果要设置对应单元格的值为某枚举项:combo.Item(combo.Index,行号).Value = Gender.Male;

            // 事件绑定 -------------------------------------------------------------
            eZdgv.DataError += EZdgvOnDataError; // 响应表格中的数据类型不匹配等出错的情况
            // eZdgv.CellContentClick += EZdgvOnCellContentClick; // 响应表格中的按钮按下事件
        }
示例#3
0
        private void ConstructeZDataGridView(eZDataGridView eZdgv,
                                             List <string> attDefs, List <AttriBlock> attBlocks)
        {
            // 基本配置

            //
            _eZdgv.KeyDelete           = true;
            _eZdgv.ManipulateRows      = false;
            _eZdgv.ShowRowNumber       = true;
            _eZdgv.SupportPaste        = true;
            _eZdgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader;
            //
            // _eZdgv.EditMode = DataGridViewEditMode.EditOnEnter;
            _eZdgv.AllowUserToAddRows  = false;
            _eZdgv.AutoGenerateColumns = true;

            _dataTable       = ConstructDataTable(attBlocks, attDefs);
            eZdgv.DataSource = _dataTable;

            // 将坐标显示为三位小数
            var dicimalStyle3 = new DataGridViewCellStyle();

            dicimalStyle3.Format = "0.###";
            eZdgv.Columns["X"].DefaultCellStyle = dicimalStyle3;
            eZdgv.Columns["Y"].DefaultCellStyle = dicimalStyle3;

            //// 设置自动排序
            foreach (DataGridViewColumn col in eZdgv.Columns)
            {
                //设置自动排序
                col.SortMode     = DataGridViewColumnSortMode.Automatic;
                col.MinimumWidth = 70;
            }

            // 事件绑定 -------------------------------------------------------------
            _eZdgv.DataError += EZdgvOnDataError; // 响应表格中的数据类型不匹配等出错的情况
            _eZdgv.ColumnHeaderMouseClick += EZdgvOnColumnHeaderMouseClick;
            _eZdgv.SelectionChanged       += EZdgvOnSelectionChanged;
        }
示例#4
0
        private void ConstructeZDataGridViewSoil(eZDataGridView eZdgv)
        {
            if (_eZDataGridViewSoilConstructed)
            {
                return;
            }

            //
            eZdgv.AutoGenerateColumns = false;
            eZdgv.ManipulateRows      = true;
            eZdgv.ShowRowNumber       = true;
            eZdgv.SupportPaste        = false;
            //

            // 创建数据列并绑定到数据源 ----------------------------------------------

            // -------------------------
            var column = new DataGridViewTextBoxColumn();

            column.Name             = "SoilHeight";
            column.DataPropertyName = "SoilHeight";
            column.HeaderText       = @"土层厚度 (m)";
            eZdgv.Columns.Add(column);

            // -------------------------
            column                  = new DataGridViewTextBoxColumn();
            column.Name             = "Kci0";
            column.DataPropertyName = "Kci0";
            column.HeaderText       = @"K_ci0";
            column.ToolTipText      = @"矩形地铁车站结构顶板上表面与地表齐平时的Kci值";
            eZdgv.Columns.Add(column);

            // 事件绑定
            eZdgv.DataError        += EZdgvOnDataError;
            eZdgv.CellValueChanged += EZdgvOnCellValueChanged;
            //
            _eZDataGridViewSoilConstructed = true;
        }
示例#5
0
        /// <summary> 将表格控件中修改后的值提取出来 </summary>
        private Dictionary <AttriBlock, Dictionary <string, string> > GetAttValuesFromEzdgv(eZDataGridView eZdgv)
        {
            var va = new Dictionary <AttriBlock, Dictionary <string, string> >();
            //
            var dt = eZdgv.DataSource as System.Data.DataTable;
            Dictionary <string, string> attDef_attValue;

            foreach (DataRow row in dt.Rows)
            {
                var hand       = (Handle)row["Handle"];
                var attriBlock = _allAttriBlocks.FirstOrDefault(r => r.Handle == hand);
                attDef_attValue = new Dictionary <string, string>();
                if (attriBlock != null)
                {
                    foreach (var attDef in _allAttDefs)
                    {
                        var c = row[attDef];
                        attDef_attValue.Add(attDef, c.ToString());
                    }
                }
                //
                va.Add(attriBlock, attDef_attValue);
            }
            //
            return(va);
        }
示例#6
0
        private void ConstructeZDataGridViewFrame(eZDataGridView eZdgv)
        {
            if (_eZDataGridViewFrameConstructed)
            {
                return;
            }

            //eZdgv.DataSource = _persons;

            eZdgv.AllowUserToAddRows  = false;
            eZdgv.AutoGenerateColumns = false;
            //
            eZdgv.ShowRowNumber  = true;
            eZdgv.ManipulateRows = false;
            eZdgv.SupportPaste   = false;

            // 创建数据列并绑定到数据源 ----------------------------------------------

            // -------------------------
            var column = new DataGridViewTextBoxColumn();

            column.DataPropertyName = "ID";
            column.Name             = "ID";
            column.AutoSizeMode     = DataGridViewAutoSizeColumnMode.DisplayedCells;
            eZdgv.Columns.Add(column);

            // -------------------------
            column                  = new DataGridViewTextBoxColumn();
            column.Name             = "ComponentType";
            column.DataPropertyName = "ComponentType";
            column.HeaderText       = @"类型";
            column.AutoSizeMode     = DataGridViewAutoSizeColumnMode.DisplayedCells;
            eZdgv.Columns.Add(column);

            // -------------------------
            column                  = new DataGridViewTextBoxColumn();
            column.Name             = "LocationTag";
            column.DataPropertyName = "LocationTag";
            column.HeaderText       = @"定位";
            eZdgv.Columns.Add(column);

            // -------------------------
            _comboColMat = new DataGridViewComboBoxColumn();
            //combo.DataSource = Enum.GetValues(typeof(Gender));
            _comboColMat.Name             = "Material";
            _comboColMat.DataPropertyName = "Material";
            _comboColMat.HeaderText       = @"材料";

            _comboColMat.DisplayMember = "Name";
            _comboColMat.ValueMember   = "Self";

            eZdgv.Columns.Add(_comboColMat);
            // 如果要设置对应单元格的值为某枚举项:combo.Item(combo.Index,行号).Value = Gender.Male;

            // -------------------------
            _comboColProf = new DataGridViewComboBoxColumn();
            //combo.DataSource = Enum.GetValues(typeof(Gender));
            _comboColProf.Name             = "Profile";
            _comboColProf.DataPropertyName = "Profile";
            _comboColProf.HeaderText       = @"截面";

            _comboColProf.DisplayMember = "Name";
            _comboColProf.ValueMember   = "Self";

            eZdgv.Columns.Add(_comboColProf);
            // 如果要设置对应单元格的值为某枚举项:combo.Item(combo.Index,行号).Value = Gender.Male;


            // 事件绑定
            eZdgv.DataError += EZdgvOnDataError;

            //
            _eZDataGridViewFrameConstructed = true;
        }
示例#7
0
        private void ConstructeZDataGridViewTunnel(eZDataGridView eZdgv)
        {
            if (_eZDataGridViewTunnelConstructed)
            {
                return;
            }

            eZdgv.AllowUserToAddRows  = false;
            eZdgv.AutoGenerateColumns = false;
            //
            eZdgv.ShowRowNumber  = true;
            eZdgv.ManipulateRows = false;
            eZdgv.SupportPaste   = false;

            // 创建数据列并绑定到数据源 ----------------------------------------------

            // -------------------------
            var column = new DataGridViewTextBoxColumn();

            column.DataPropertyName = "ID";
            column.Name             = "ID";
            column.AutoSizeMode     = DataGridViewAutoSizeColumnMode.DisplayedCells;
            eZdgv.Columns.Add(column);

            // -------------------------
            column                  = new DataGridViewTextBoxColumn();
            column.Name             = "LocationTag";
            column.DataPropertyName = "LocationTag";
            column.HeaderText       = @"定位";
            eZdgv.Columns.Add(column);


            // -------------------------
            _comboColMat                  = new DataGridViewComboBoxColumn();
            _comboColMat.Name             = "Material";
            _comboColMat.DataPropertyName = "Material";
            _comboColMat.HeaderText       = @"材料";
            _comboColMat.DisplayMember    = "Name";
            _comboColMat.ValueMember      = "Self";
            eZdgv.Columns.Add(_comboColMat);


            // -------------------------
            _comboColProf                  = new DataGridViewComboBoxColumn();
            _comboColProf.Name             = "Profile";
            _comboColProf.DataPropertyName = "Profile";
            _comboColProf.HeaderText       = @"截面";
            _comboColProf.DisplayMember    = "Name";
            _comboColProf.ValueMember      = "Self";
            eZdgv.Columns.Add(_comboColProf);

            //给 DataGridView 的定位列添加注释
            eZDataGridViewTunnel.ShowCellToolTips       = true;
            eZDataGridViewTunnel.Columns[1].ToolTipText = "通过二维向量(θ1,θ2)表示该管片起始节点的角度为θ1°,终止节点的角度为θ2°,其中0°表示圆管水平向的右侧点,逆时针旋转为正";

            // 事件绑定
            eZdgv.DataError += EZdgvOnDataError;

            //
            _eZDataGridViewTunnelConstructed = true;
        }