■ はじめに
https://blogs.yahoo.co.jp/dk521123/38051736.htmlにおいて、PictureBox 1つで画像比較スライダーを実装したが 左側と右側で別のToolTip(ツールチップ)を表示したいので調べてみた。
■ サンプル
https://blogs.yahoo.co.jp/dk521123/38051736.htmlをベースにToolTipに関する処理について抜粋する
ToolTipに関する処理を抜粋
「★★★ この部分を追加 / ここから ★★★」に注目 private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (this.srcImage == null || this.destinationImage == null)
{
return;
}
// ★★★ この部分を追加 / ここから ★★★
var pictureBox = sender as PictureBox;
string toolTipText;
if (e.X <= this.borderPosition)
{
toolTipText = "左側の画像です";
}
else
{
toolTipText = "右側の画像です";
}
if (!toolTipText.Equals(this.toolTip1.GetToolTip(pictureBox)))
{
//アクティブを解除
if (this.toolTip1.Active)
{
this.toolTip1.Active = false;
}
this.toolTip1.SetToolTip(pictureBox, toolTipText);
this.toolTip1.Active = true;
}
// ★★★ この部分を追加 / ここまで ★★★
var mousePoint = e.Location;
if (this.IsOnBorderArea(mousePoint, this.borderPosition, this.destinationImage.Height))
{
this.pictureBox1.Cursor = Cursors.VSplit;
}
else
{
this.pictureBox1.Cursor = Cursors.Default;
}
// 以降は、省略。
参考文献
http://dobon.net/vb/dotnet/control/lvitemtooltip.htmlhttps://dobon.net/vb/bbs/log3-13/7524.html
https://www.codeproject.com/Questions/237644/How-use-different-tooltip-text-on-one-picture-box
関連記事
Windows Form
Windows Form ~ 目次 ~https://blogs.yahoo.co.jp/dk521123/8054245.html
Tooltip (ツールチップ) [1]
https://blogs.yahoo.co.jp/dk521123/37850847.html
PictureBox [8] ~ 画像比較スライダーをWindows Formで実装する ~
https://blogs.yahoo.co.jp/dk521123/38051736.html