Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4051070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:08:55+00:00 2026-05-20T14:08:55+00:00

I have a ListView. I want to select the first element from it and

  • 0

I have a ListView. I want to select the first element from it and then invoke a method. The thing is that though i have the element in the listview I dont know why the following code is not working when i want to select the element. need help. thx

listview.Items[0].Selected = true;
listview.Select();
int c =listview.SelectedItems.Count;
MessageBox.Show(c + ": and : " + listview.Items[0].ToString()); .//here the c=0 and it should be 1:(
//  Thread.Sleep(3000);
method();  

I have:

ListViewItem it = new ListViewItem("a");
it.SubItems.Add("s");
it.SubItems.Add(""v");
it.Tag = call;
listview.Items.Add(it);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:08:56+00:00Added an answer on May 20, 2026 at 2:08 pm

    for

    System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("fdasf");
    System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("sdfsadf");
    System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("gdsgdfg");
    

    and

    this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
        listViewItem4,
        listViewItem5,
        listViewItem6});
    this.listView1.Location = new System.Drawing.Point(84, 88);
    this.listView1.Name = "listView1";
    this.listView1.Size = new System.Drawing.Size(121, 97);
    this.listView1.TabIndex = 0;
    this.listView1.UseCompatibleStateImageBehavior = false;
    this.listView1.View = System.Windows.Forms.View.List;
    

    this works and c is 1

    listView1.Items[0].Selected = true;
    listView1.Select();
    int c =listView1.SelectedItems.Count;
    MessageBox.Show(c + ": and : " + listView1.Items[0].ToString());
    //  Thread.Sleep(3000);
    method();  
    

    enter image description here

    The problem is probably somewhere else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview with a DataTemplate that has a ComboBox. I want the
I have a datasource that I want to bind to a listview that has
I have a listview that displays files from a directory. The user can drag
I have something like that: <asp:ListView ID=lvList runat=server> <LayoutTemplate> <select id=select_list> <option value=-1> select
I currently have a listview and I want to add an appropriate icon to
i want to display some information in a listview using the GridView. i have
I have a page with a number of ListViews that I want users to
I have a ListView in WPF that is databound to a basic table that
I have a ListView on a page that displays a list of widgets. When
I have a listview with a textview as each item. I want to change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.