掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ListViewのMouseDown時のColumnIndex (ID:140723)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
MSDNライブラリで下記のようにListViewのMouseDownにより、該当 するItemおよびその場所にあるSubItemを得ることができることが わかりました。 ListView1.View = View.Details のとき、対応するColumnHedder あるいはそのIndexを得るにはどのような方法がありますでしょうか? 該当するSubItemがNothingの場合も可能な方法を考えています。 #各ColumnHedderのX座標でもわかれば計算できそうな気もしますが #横スクロールの具合により判断が大変な予感がします。 Private Sub listView1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) ' Get the item at the mouse pointer. Dim info As ListViewHitTestInfo = listView1.HitTest(e.X, e.Y) Dim subItem As ListViewItem.ListViewSubItem = Nothing ' Get the subitem 120 pixels to the right. If (info IsNot Nothing) Then If (info.Item IsNot Nothing) Then subItem = info.Item.GetSubItemAt(e.X + 120, e.Y) End If End If ' Show the text of the subitem, if found. If (subItem IsNot Nothing) Then MessageBox.Show(subItem.Text) End If End Sub
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.