Exemplo n.º 1
0
        private void ConfigGridView()
        {
            if (!DesignMode)
            {
                if (_gridControl == null)
                {
                    return;
                }
                TSCommon.SetGridControl(_gridControl);
                TSCommon.SetGridControlColumnsBind(_gridControl, _columnBind);

                #region 添加编辑删除按钮
                GridView mainView = (GridView)_gridControl.MainView;
                if (!BrowseMode && !ChooseMode)
                {
                    if (HasView)
                    {
                        RepositoryItemHyperLinkEdit linkView = new RepositoryItemHyperLinkEdit();
                        GridColumn gc_view = new GridColumn();
                        gc_view.Caption    = "查看";
                        gc_view.Name       = "gc_view";
                        gc_view.FieldName  = "view";
                        gc_view.ColumnEdit = linkView;
                        gc_view.Width      = 32;
                        gc_view.OptionsColumn.FixedWidth = true;
                        gc_view.Visible = true;
                        mainView.Columns.Add(gc_view);
                    }
                    if (HasEdit)
                    {
                        RepositoryItemHyperLinkEdit linkEdit = new RepositoryItemHyperLinkEdit();
                        GridColumn gc_edit = new GridColumn();
                        gc_edit.Caption    = "编辑";
                        gc_edit.Name       = "gc_edit";
                        gc_edit.FieldName  = "edit";
                        gc_edit.ColumnEdit = linkEdit;
                        gc_edit.Width      = 32;
                        gc_edit.OptionsColumn.FixedWidth = true;
                        gc_edit.Visible = true;
                        mainView.Columns.Add(gc_edit);
                    }
                    if (HasDel)
                    {
                        RepositoryItemHyperLinkEdit linkDel = new RepositoryItemHyperLinkEdit();
                        GridColumn gc_del = new GridColumn();
                        gc_del.Caption    = "删除";
                        gc_del.Name       = "gc_del";
                        gc_del.FieldName  = "del";
                        gc_del.ColumnEdit = linkDel;
                        gc_del.Width      = 32;
                        gc_del.OptionsColumn.FixedWidth = true;
                        gc_del.Visible = true;
                        mainView.Columns.Add(gc_del);
                    }
                }
                #endregion

                //单元格点击事件
                mainView.RowCellClick += (object sender, RowCellClickEventArgs e) => OnRowCellClick(e);
            }
        }