0
item1.SubItems.Add(varintx[x]);
// my code //

ERROR CS1503 C# Argument 1: cannot convert from 'int' to "System.Windows.Forms.ListViewItem.ListViewSubItem"

How to add a "int array" like a subitem of a listview

2
  • Use varintx[x].ToString() Commented Dec 2, 2017 at 16:43
  • the error message clearly tells you what the issue is, cannot convert Convert being the key word , from into to ListViewItem.ListViewSubItem doing a msdn search on the error or google would tell you the data type that SubItem is expecting.. I would refresh yourself on the .ToString() extension method as well as the Convert.ToString()` method when you get a chance Commented Dec 2, 2017 at 16:48

1 Answer 1

2
for (Int32 i = 0; i < varintx.Length; ++i)
{
    ListViewItem item = new ListViewItem();
    item.SubItems.Add(varintx[i].ToString());

    myListVIew.Items.Add(item);
}

You have to convert your int values to string before passing them to the ListViewItem. So your code excerpt should be rewritten as follows:

item1.SubItems.Add(varintx[x].ToString());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.