ListViewItem.GetSubItemAt メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ListViewItem.GetSubItemAt メソッドの意味・解説 

ListViewItem.GetSubItemAt メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

ListViewItem の指定した座標にあるサブ項目を返します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Function GetSubItemAt ( _
    x As Integer, _
    y As Integer _
) As ListViewSubItem
Dim instance As ListViewItem
Dim x As Integer
Dim y As Integer
Dim returnValue As ListViewSubItem

returnValue = instance.GetSubItemAt(x, y)
public ListViewSubItem GetSubItemAt (
    int x,
    int y
)
public:
ListViewSubItem^ GetSubItemAt (
    int x, 
    int y
)
public ListViewSubItem GetSubItemAt (
    int x, 
    int y
)
public function GetSubItemAt (
    x : int, 
    y : int
) : ListViewSubItem

パラメータ

x

x 座標

y

y 座標

戻り値
指定した x 座標および y 座標にある ListViewItem.ListViewSubItem。

解説解説

GetSubItemAt メソッドは、ListView が Details ビューない場合、または指定した位置ListViewItem.ListViewSubItem存在しない場合には、null 参照 (Visual Basic では Nothing) を返します

使用例使用例

GetSubItemAt メソッド使用する方法次のコード例示します。このコード実行するには、コードWindows フォーム貼り付けフォームコンストラクタまたは Loadイベント処理メソッドから InitializeListView1呼び出します。

Private WithEvents listView1 As
 ListView

Private Sub InitializeListView1()
    listView1 = New ListView()

    ' Set the view to details to show subitems.
    listView1.View = View.Details

    ' Add some columns and set the width.
    listView1.Columns.Add("Name")
    listView1.Columns.Add("Number")
    listView1.Columns.Add("Description")
    listView1.Width = 175

    ' Create some items and subitems; add the to the ListView.
    Dim item1 As New ListViewItem("Widget")
    item1.SubItems.Add(New ListViewItem.ListViewSubItem(item1,
 "14"))
    item1.SubItems.Add(New ListViewItem.ListViewSubItem(item1,
 "A description of Widget"))
    Dim item2 As New ListViewItem("Bracket")
    item2.SubItems.Add(New ListViewItem.ListViewSubItem(item2,
 "8"))
    listView1.Items.Add(item1)
    listView1.Items.Add(item2)

    ' Add the ListView to the form.
    Me.Controls.Add(listView1)
End Sub

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 Not (info Is Nothing)
 Then
        If Not (info.Item Is
 Nothing) Then
            subItem = info.Item.GetSubItemAt(e.X + 120, e.Y)
        End If
    End If ' Show the text of
 the subitem, if found.
    If Not (subItem Is Nothing)
 Then
        MessageBox.Show(subItem.Text)
    End If
End Sub
private ListView listView1;

private void  InitializeListView1(){
    listView1 = new ListView();
    
    // Set the view to details to show subitems.
    listView1.View = View.Details;
   
    // Add some columns and set the width.
    listView1.Columns.Add("Name");
    listView1.Columns.Add("Number");
    listView1.Columns.Add("Description");
    listView1.Width = 175;

    // Create some items and subitems; add the to the ListView.
    ListViewItem item1 = new ListViewItem("Widget");
    item1.SubItems.Add(new ListViewItem.ListViewSubItem(item1,
 "14"));
    item1.SubItems.Add(new ListViewItem.ListViewSubItem(item1,
 
        "A description of Widget"));
    ListViewItem item2 = new ListViewItem("Bracket");
    item2.SubItems.Add(new ListViewItem.ListViewSubItem(item2,
 "8"));
    listView1.Items.Add(item1);
    listView1.Items.Add(item2);
    
    // Add the ListView to the form.
    this.Controls.Add(listView1);
    listView1.MouseDown += new MouseEventHandler(listView1_MouseDown);
}

void listView1_MouseDown(object sender, MouseEventArgs e)
{
    // Get the item at the mouse pointer.
    ListViewHitTestInfo info = listView1.HitTest(e.X, e.Y);

    ListViewItem.ListViewSubItem subItem = null;
    
    // Get the subitem 120 pixels to the right.
    if (info != null)
        if (info.Item != null)
            subItem = info.Item.GetSubItemAt(e.X + 120, e.Y);
    
    // Show the text of the subitem, if found.
    if (subItem != null)
        MessageBox.Show(subItem.Text);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からListViewItem.GetSubItemAt メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からListViewItem.GetSubItemAt メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からListViewItem.GetSubItemAt メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ListViewItem.GetSubItemAt メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ListViewItem.GetSubItemAt メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS