FarPoint.Win.Spread 表格 鼠标悬停 展示表格数据 并且控制每行字数 代码备忘

      注册事件,并进行配置 

  //鼠标悬停 显示相关
            this.spdMain.TextTipFetch += new FarPoint.Win.Spread.TextTipFetchEventHandler(this.spdMain_TextTipFetch);
            FarPoint.Win.Spread.TipAppearance app = new FarPoint.Win.Spread.TipAppearance();
            //app.BackColor = Color.Bisque;
            app.BackColor = Color.AliceBlue;
            app.Font = new Font("", 12);//设置字体
            app.ForeColor = Color.Red;
            spdMain.TextTipAppearance = app;
            spdMain.TextTipDelay = 300;
            spdMain.TextTipPolicy = FarPoint.Win.Spread.TextTipPolicy.Floating;

实现方法:

 /// <summary>
        /// 鼠标悬停展示相关
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void spdMain_TextTipFetch(object sender, FarPoint.Win.Spread.TextTipFetchEventArgs e)
        {
            //控制每行显示字符个数
            int rowShowLength = 15;
            string tipText = e.TipText;
            int tipTextLength =  tipText.Length;
            StringBuilder sb = new StringBuilder();
            if (tipText.Length > rowShowLength)
            {
                for (int i = 0; i < tipTextLength / rowShowLength; i++)
                {
                    sb.Append(tipText.Substring(rowShowLength * i, rowShowLength )).Append(Environment.NewLine);
                }
                if (tipTextLength % rowShowLength > 0)
                {
                    int index = rowShowLength * (tipTextLength / rowShowLength);
                    sb.Append(tipText.Substring(rowShowLength * (tipTextLength / rowShowLength), tipTextLength - index));
                }
            }
            else
                sb.Append(tipText);
            e.TipText = sb.ToString(); 

            //展示
            e.ShowTip = true;
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值