Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ListView

ListView

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benjamin yap
    wrote on last edited by
    #1

    Hi, i got 2 list view on 1 form. the first list view shows the product name and the other listview show the supplier name. the user have to first select a item from the product list view , then select another item from the supplier list view. By now, both selected items should be highlighted. When i press the ok button, i wan to know in product list box, what the user selected and in the supplier list box, what the user selected. However when i select 1 item from product, then i select the other item from supplier, the product list view is being disselected

            DataTable dt = new DataTable();
            dt = pa.GetData();
            foreach (DataRow rows in dt.Rows)
            {
                ListViewItem product = new ListViewItem();
                product = listView1.Items.Add(Convert.ToString(rows\["productID"\]));
                product.SubItems.Add(Convert.ToString(rows\["name"\]));
                product.SubItems.Add(Convert.ToString(rows\["modelNo"\]));
            }
    
            DataTable dt1 = new DataTable();
            dt1 = sa.GetData();
    
            foreach (DataRow rows in dt1.Rows)
            {
                ListViewItem supplier = new ListViewItem();
                supplier = listView2.Items.Add(Convert.ToString(rows\["companyName"\]));
                supplier.SubItems.Add(Convert.ToString(rows\["contactName"\]));
            }
    
    K 1 Reply Last reply
    0
    • B benjamin yap

      Hi, i got 2 list view on 1 form. the first list view shows the product name and the other listview show the supplier name. the user have to first select a item from the product list view , then select another item from the supplier list view. By now, both selected items should be highlighted. When i press the ok button, i wan to know in product list box, what the user selected and in the supplier list box, what the user selected. However when i select 1 item from product, then i select the other item from supplier, the product list view is being disselected

              DataTable dt = new DataTable();
              dt = pa.GetData();
              foreach (DataRow rows in dt.Rows)
              {
                  ListViewItem product = new ListViewItem();
                  product = listView1.Items.Add(Convert.ToString(rows\["productID"\]));
                  product.SubItems.Add(Convert.ToString(rows\["name"\]));
                  product.SubItems.Add(Convert.ToString(rows\["modelNo"\]));
              }
      
              DataTable dt1 = new DataTable();
              dt1 = sa.GetData();
      
              foreach (DataRow rows in dt1.Rows)
              {
                  ListViewItem supplier = new ListViewItem();
                  supplier = listView2.Items.Add(Convert.ToString(rows\["companyName"\]));
                  supplier.SubItems.Add(Convert.ToString(rows\["contactName"\]));
              }
      
      K Offline
      K Offline
      Kjetil Svendsen
      wrote on last edited by
      #2

      Hi. Try setting

      ListView.HideSelection = false;

      Kjetil

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups