Please some body help me with my codes i am getting ArguementOutofRange Exception again & again. Please tell me what am i doing wrong. I tried every loop for this but it always gives ArgueOutofrange Error.
Exception is:-
"InvelidArguement = value of '3' is not valid for 'SelectedIndex'. Parameter name: SelectedIndex"
&
Warning is:
"The result of the exception is always 'true' since a value of type 'int' is never equal to 'null' of type 'int?'"
this is my code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listBox1.Items.Add("www.google.com");
listBox1.Items.Add("www.facebook.com");
listBox1.Items.Add("www.yahoo.com");
listBox1.SelectedIndex = 0;
listBox1.DataSource = listBox1.Items;
}
private void button1_Click(object sender, EventArgs e)
{
var num = listBox1.Items.Count;
string str = Convert.ToString(num);
textBox1.Text = str;
for (int i = 0; i < num; )
{
webBrowser1.Navigate(listBox1.SelectedItem.ToString());
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
}
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
var num = listBox1.Items.Count;
string str = Convert.ToString(num);
textBox1.Text = str;
}
}