[.NETコントロール] RasterImageListコントロールにツールチップを表示できますか?
対象製品
LEADTOOLS 17.5J Imaging Pro Suite
詳細
.NET FrameworkのToolTipクラスを使用することでRasterImageListコントロールにツールチップを追加することができます。ToolTipクラスのSetToolTipメソッドの第1引数で、RasterImageListコントロールを設定してください。
サンプルコード(VB.NET)
サンプルコード(C#)
サンプルコード(VB.NET)
Private codecs As RasterCodecs Private toolTip As ToolTip Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) toolTip = New ToolTip() codecs = New RasterCodecs() RasterImageList1.Items.Add(New RasterImageListItem(codecs.Load("test1.jpg"), 1, "test1.jpg")) RasterImageList1.Items.Add(New RasterImageListItem(codecs.Load("test2.jpg"), 1, "test2.jpg")) RasterImageList1.Items.Add(New RasterImageListItem(codecs.Load("test3.jpg"), 1, "test3.jpg")) End Sub Private Sub RasterImageList1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Dim rili As RasterImageListItem = RasterImageList1.HitTest(e.X, e.Y) If rili IsNot Nothing Then If rili.Text <> toolTip.GetToolTip(RasterImageList1) Then toolTip.Hide(RasterImageList1) toolTip.SetToolTip(RasterImageList1, rili.Text) End If Else toolTip.Show("", RasterImageList1) End If End Sub
サンプルコード(C#)
private RasterCodecs codecs; private ToolTip toolTip; private void Form1_Load(object sender, EventArgs e) { toolTip = new ToolTip(); codecs = new RasterCodecs(); rasterImageList1.Items.Add(new RasterImageListItem(codecs.Load(@"test1.jpg"), 1, "test1.jpg")); rasterImageList1.Items.Add(new RasterImageListItem(codecs.Load(@"test2.jpg"), 1, "test2.jpg")); rasterImageList1.Items.Add(new RasterImageListItem(codecs.Load(@"test3.jpg"), 1, "test3.jpg")); } private void rasterImageList1_MouseMove(object sender, MouseEventArgs e) { RasterImageListItem rili = rasterImageList1.HitTest(e.X, e.Y); if (rili != null) { if (rili.Text != toolTip.GetToolTip(rasterImageList1)) { toolTip.Hide(rasterImageList1); toolTip.SetToolTip(rasterImageList1, rili.Text); } } else { toolTip.Show("", rasterImageList1); } }
関連情報
キーワード
HowTo 画像の表示 マウス操作