Hi,
how to covert integer value to double in listview subitems.
pls reply me as soon as possible
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Dec 20, 2014, 7:12 AM
public double subtot()
{
int i = 0;
int j = 0;
double k = 0;
try
{
j = ListView1.Items.Count;
for (i = 0; i <= j - 1; i++)
{
k = k + Convert.ToDouble(ListView1.Items[i].SubItems[6].Text);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return 0;
}
return k;
}
SatPosted Dec 20, 2014, 7:17 AM
SatPosted Dec 20, 2014, 4:26 AM
{
if (ListView1.Items.Count == 0)
{
ListViewItem lsv = new ListViewItem();
cmbCategory.Enabled = true;
cmbCategory.Enabled = true;
lsv.SubItems.Add(txtItemCode.Text);
lsv.SubItems.Add(txtProductName.Text);
lsv.SubItems.Add(txtPrice.Text);
lsv.SubItems.Add(txtAvailableQty.Text);
lsv.SubItems.Add(textBox2.Text);
lsv.SubItems.Add(txtTotalAmount.Text);
lsv.SubItems.Add(cmbItem.SelectedValue.ToString());
lsv.SubItems.Add(cmbCategory.Text);
lsv.SubItems.Add(cmbItem.Text);
ListView1.Items.Add(lsv);
txtTotal.Text = subtot().ToString();
return;
}
public double subtot()
{
int i = 0;
int j = 0;
int k = 0;
i = 0;
j = 0;
k = 0;
try
{
j = ListView1.Items.Count;
for (i = 0; i <= j - 1; i++)
{
k = k + Convert.ToInt32(ListView1.Items[i].SubItems[6].Text);
}
}
}
This is my code. if the Subitems[6] value decimal means (that means total amount) i am getting input string is not valid error. how to i get even decimal value also
Joginder BangerPosted Dec 20, 2014, 4:03 AM