Developer Express 第三方控件使用系列方法

     本人目前从事的开发工作主要是以C#语言进行的相关C/S的开发,在工作中也要求使用Developer Express第三方控件所以这一系列的控件使用说明都将以C#语言进行代码说明。平时工作中会慢慢的收集并总结一些此类控件的使用方法,但很少去写此类的一些博客,所以写的时候可能会比较乱,但我会慢慢改进不断更新,希望通过个人的以及借鉴的一些经验分享能够帮助大家更好的使用Developer Express。

   首先讲一个今天刚搞的GridControl绑定toolTipController控件,显示动态友好的tooltip提示。

        在界面上添加DEV的toolTipController控件,在GridControl的属性toolTipController中为其指定对应的toolTipController控件,一种绑定,然后就是我们伟大的toolTipController控件的事情啦,代码如下:        

private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            GridControl gctl = e.SelectedControl as GridControl;
            if (gctl == null) return;
            ToolTipControlInfo Tooltip = null;
            try
            {
                GridView View = gctl.GetViewAt(e.ControlMousePosition) as GridView;
                if (View == null) return;
                GridHitInfo HitInfo = View.CalcHitInfo(e.ControlMousePosition);
                if (HitInfo.InRowCell)
                {
                    Tooltip = new ToolTipControlInfo(new CellToolTipInfo(HitInfo.RowHandle, HitInfo.Column, "MR_OTHER_NAME"), GetCellHitText(View, HitInfo.RowHandle, HitInfo.Column));
                    Tooltip.Title = View.GetRowCellDisplayText(HitInfo.RowHandle, HitInfo.Column);//设置tooltip标题,根据需要设定
                    return;
                }
                if (HitInfo.HitTest == GridHitTest.RowIndicator)
                {
                    Tooltip = new ToolTipControlInfo(GridHitTest.RowIndicator.ToString() + HitInfo.RowHandle.ToString(), "Row Handle: " + HitInfo.RowHandle.ToString());
                    Tooltip.Title = View.GetRowCellDisplayText(HitInfo.RowHandle, HitInfo.Column);//设置tooltip标题,根据需要设定
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                e.Info = Tooltip;
            }
        }

   上面代码中的GetCellHitText方法主要是需要显示在tooltip里面的具体内容,代码如下:

        /// <summary>
        /// 函数:GetCellHitText
        /// 功能:获取目标关键字的内容文本
        /// </summary>
        /// <param name="view"></param>
        /// <param name="rowHandle"></param>
        /// <param name="gridColumn"></param>
        /// <returns></returns>
        private string GetCellHitText(GridView view, int rowHandle, GridColumn gridColumn)
        {
            //此方法是为了需要在tooltip中显示的内容需要另外转译等添加的,如只是简单的提示可以省略此方法
            string strTipContent = string.Empty;
            if (gridColumn.FieldName == "OTHER_NAME")
            {
                string strCode = view.GetRowCellDisplayText(rowHandle, "CODE");

                strTipContent = FileInter.GetDetailContent(strCode, true);//获取详细信息
            }
            return strTipContent;
        }

  以上是简单的陈述了下如何在gridControl上绑定toolTipController控件。关于toolTipController的显示效果属性中都比较明显的可以找到,这里就不再进行过多说明,希望能够帮到需要的人,当然如果存在问题也请大神们多多指点!

        

        

    

  

Best Wish !
原文地址:https://www.cnblogs.com/ultimateWorld/p/Le_ZM.html