表单内容可修改//单元格光标选中//EventList(DevExpress)

 private void InitControl()
        {
            this.gdvDetail.OptionsBehavior.Editable = true;//表单内容可修改
            this.gdvDetail.OptionsSelection.EnableAppearanceFocusedCell = true;//光标选择单元格
        }

======================

EventList

  #region Control Event 
//模拟行双击事件
        private void gdvDetail_DoubleClick(object sender, EventArgs e)
        {
            MouseEventArgs arg = e as MouseEventArgs;
            if (arg == null || arg.Button != MouseButtons.Left)
            {
                return;
            }

            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo = gdvDetail.CalcHitInfo(new Point(arg.X, arg.Y));//获取坐标点
            if (hitInfo.RowHandle >= 0)
            {
                //取得选定行信息 
                string nodeID = gdvDetail.GetRowCellValue(hitInfo.RowHandle, "EVENT_ID").ToString();
                string sModelVer = cboModelVer.EditValue.ToString();
                string sIndexes = "LOOKUP";
                //frmFDCEventSetup frm = new frmFDCEventSetup("frm", new string[] { sIndexes, GlobalVariable.gsFactory, nodeID, sModelVer });
                //string nodeName = gdvDetail.GetRowCellValue(hitInfo.RowHandle, "PRV_GRP_DESC").ToString();
                CommonFunction.OpenForm(CommonFunction.GetMenuTag(GlobalConstant.FORMID_FDC_EVENT_SETUP),
                    "Event - "+ nodeID, new string[] { sIndexes, GlobalVariable.gsFactory, nodeID, sModelVer });
                //CommonFunction.OpenForm(mTag, "Privilege Group - " + nodeName, new string[] { GlobalVariable.gsFactory, nodeID });
            }
        }

        #endregion

        #region   Item Add Data
        //向"MODULE_VER"下拉列表中添加数据
        private void cboModelVerAddData()
        {
            DataTable dt = ListRoutineFDC.ViewFDCResModelVersionList(sProcStep: '2');
            DataRow dr = dt.NewRow();
            dr[0] = "";
            dt.Rows.InsertAt(dr, 0);

            DevGridLookupHelper.InitPopup(this.cboModelVer, new string[] { "选择模块ID" }, dt);

        }
        #endregion

        #region   select many
        private int GetRowAt(GridView view, int x, int y)
        {
            return view.CalcHitInfo(new Point(x, y)).RowHandle;
        }

        //鼠标按下触发gdvPO_MouseDown事件
        private void gdvDetail_MouseDown(object sender, MouseEventArgs e)
        {
            StartRowHandle = GetRowAt(sender as GridView, e.X, e.Y);
        }

        //鼠标松开触发gdvPO_MouseDown事件
        private void gdvDetail_MouseUp(object sender, MouseEventArgs e)
        {
            StartRowHandle = -1;
            CurrentRowHandle = -1;
            timer1.Stop();
        }

        private void SelectRows(GridView view, int startRow, int endRow)
        {
            if (startRow > -1 && endRow > -1)
            {
                view.BeginSelection();
                view.ClearSelection();
                view.SelectRange(startRow, endRow);
                view.EndSelection();
            }
        }

        private void gdvDetail_MouseMove(object sender, MouseEventArgs e)
        {


            if (e.Button == MouseButtons.Left)
            {
                GridView view = sender as GridView;
                GridViewInfo info = view.GetViewInfo() as GridViewInfo;
                GridHitInfo hi = view.CalcHitInfo(e.Location);

                int newRowHandle = GetRowAt(sender as GridView, e.X, e.Y);
                if (CurrentRowHandle != newRowHandle)
                {
                    CurrentRowHandle = newRowHandle;
                    SelectRows(sender as GridView, StartRowHandle, CurrentRowHandle);
                }
                if (info.RowsInfo.Count < 1)
                {
                    return;
                }
                if (info.RowsInfo.Count >= 2 && info.RowsInfo[info.RowsInfo.Count - 2].RowHandle == hi.RowHandle)
                {
                    scrollDown = true;
                    if (!timer1.Enabled)
                        timer1.Start();
                }
                else
                {
                    if (info.RowsInfo[0].RowHandle == hi.RowHandle)
                    {
                        scrollDown = false;
                        if (!timer1.Enabled)
                            timer1.Start();
                    }
                    else
                        timer1.Stop();
                }
            }
        }


 private void timer1_Tick(object sender, EventArgs e)
        {
            if (scrollDown)
            {
                gdvDetail.TopRowIndex++;
            }
            else
            {
                gdvDetail.TopRowIndex--;
            }
            Point ee = gdcDetail.PointToClient(MousePosition);
            int newRowHandle = GetRowAt(gdvDetail, ee.X, ee.Y);
            if (CurrentRowHandle != newRowHandle)
            {
                CurrentRowHandle = newRowHandle;
                SelectRows(gdvDetail, StartRowHandle, CurrentRowHandle);
            }
        }
        #endregion

 

转载于:https://my.oschina.net/8824/blog/3095370

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值