Vuk Stanojevic

Vuk Stanojevic

  • 1.6k
  • 140
  • 45.6k

'InvalidArgument=Value of '1' is not valid for 'index'.

Apr 5 2020 9:24 AM
Hi Everyone,
i have error System.ArgumentOutOfRangeException: 'InvalidArgument=Value of '1' is not valid for 'index'.
Error appears in doubleclick listview command.
Listview details are:
if (Service != null)
{
FindItemsResults<Item> findResults = Service.FindItems(WellKnownFolderName.Inbox ,new ItemView(1000));
foreach (Item item in findResults)
{
EmailMessage message = EmailMessage.Bind(Service,item.Id);
string date = message.DateTimeReceived.ToString();
string from = message.From.Name.ToString();
string body = message.Body.ToString();
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add(date);
item1.SubItems.Add(from);
item1.SubItems.Add(body);
listView1.Items.Add(item1);
}
}
listview_doubleclick command is:
Form2 form2 = new Form2();
form2.textBox1.Text = listView1.SelectedItems[0].Text.ToString();
form2.textBox2.Text = listView1.SelectedItems[1].Text.ToString();
form2.textBox3.Text = listView1.SelectedItems[2].Text.ToString();
form2.ShowDialog();
form2.Textbox1.Text= works OK it load correct information's (date)
But for form2.Textbox2 and form2.Textbox3 i get error which is in subject.
Can you please help?

Answers (6)