ListView
-
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"\])); }
-
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"\])); }
Hi. Try setting
ListView.HideSelection = false;
Kjetil