c# - get the value of a listview subitem -
I have the code in C # I have a list view, so I want the value of subitum in particular Sub-subtle submission should meet in which the sub-sum values of the order are included. I want to add value and want to display as a result of the text box in the same form. How can I do that? Here is my code:
AddOrderForm Add = New AddOrderForm (); Foreign currency (DataRow drow in dt.ows) {add.nametb.Text = drow ["menu"]. ToString (); Add.Pricetb.Text = drow ["MenuPrice"]. ToString (); Add.listBox1.Items.Add (drow ["MenuDesc"] ToString ().); Add.orderqtytb.Focus (); Add.ShowDialog (); } If (add.isAddOrder) {ListViewItem item = New ListViewItem (); Item.Text = add.nametb.Text; Item.SubItems.Add (add.orderqtytb.Text); Item.SubItems.Add (add.Pricetb.Text); Double total = 0; Try {Total = double.Parse (add.Pricetb.Text) * Double. Purse (add.orderqtytb.Text); } Hold {total = 0; } Items. SubItems.Add (total.ToString ("0.00")); Listview.Items.Add (item);
You can return a item You can get> Sub-item ListView in this way Assume that your ListView is like this: < Pre> Public Zero AddDataToLvw () {ListViewItem Item1 = New list view item ("item 1", 0); Item1.SubItems.Add ("1"); Item1.SubItems.Add ("3"); ListViewItem item2 = New ListViewItem ("item2", 1); Item2.SubItems.Add ("4"); Item2.SubItems.Add ("6"); ListViewItem item3 = New ListViewItem ("item3", 0); Item3.SubItems.Add ("7"); Item3.SubItems.Add ("9"); // Create columns for items and sub-themes. ListView1.Columns.Add ("Item column", -2, horizontal alignment left); ListView1.Columns.Add ("column2", -2, horizontal alignment.lift); List view 1. Columns Add ("Column 3", -2, Horizontal Alignment. Lift); ListView1.Items.AddRange (New ListViewItem [] {item1, item2, item3}); } After that you can use such subitems:
Private Zero GetSubItems () {int total = 0; FirstHatch (item list in list view list 1. Items) {Total + = Convert ToInt32 (Items. SubItems [1]. Text); MessageBox.Show (total.ToString ()); } Notice the index that I passed in the items. SubItems . You should give a subtitle index that you want to summarize
Comments
Post a Comment