注册事件,并进行配置
//鼠标悬停 显示相关
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;
}