I have a listbox.item.count and it is in a loop. With this loop int m is included
Now I have as follow:
private void button4_Click(object sender, EventArgs e)
{
int y = listBox1.Items.Count;
for ( m = 0; m < listBox1.Items.Count; m++)
{
for ( a = 1; a <= 5; a++)
{
this.halo();
}
}
if ( m = = listBox1.Items.Count)
{
m = 0;
......................................;
}
}
private void halo()
{
dataGridView1.Rows.Add(a, listBox1.Items[m].ToString());
}
I don't know in the part where ..........................; to go start back again in the listbox1.Item.Count loop
Loading
Arnold PetronaPosted Jul 24, 2008, 3:23 PM
Ok thanks it works fine.
No another little question. Now in mine datagridView1.Rows.Add(col1, col2)
it repeat himself several of times.
Now my idea is when it comes to an end it start back again at the first Row. This means that the first result example Name : Arnold Age : 17 every time will be display in the first Column
Satish KathiPosted Jul 24, 2008, 2:34 PM
If you want to do with the button here is the Code. But the application will Hang, though you can view the results.
private void button2_Click(object sender, EventArgs e)
{
while (1 == 1)
{
for (int m = 0; m < listBox1.Items.Count; m++)
{
for (int a = 1; a <= 5; a++)
{
this.halo(a, listBox1.Items[m].ToString());
}
}
Application.DoEvents();
Thread.Sleep(10000);
}
}
private void halo(int col1, string col2)
{
dataGridView1.Rows.Add(col1, col2);
}
But I won’t prefer above code, application hangs
Here is the code what Ryan has suggested (I prefer). This will work Fine
private void timer1_Tick(object sender, EventArgs e)
{
for (int m = 0; m < listBox1.Items.Count; m++)
{
for (int a = 1; a <= 5; a++)
{
this.halo(a, listBox1.Items[m].ToString());
}
}
}
private void halo(int col1, string col2)
{
dataGridView1.Rows.Add(col1, col2);
}
Try to avoid using GoTo statement
Arnold PetronaPosted Jul 24, 2008, 2:03 PM
Ok, I tried to do something but it is still hanging.
My Code is as follow:
private void button4_click( object sender, EverArgs e)
{
int y = listBox1.Items.Count;
begin:
for ( int m = 0 ; m
{
for ( int a = 1 ; a<=5 ; a++)
{
this.halo();
}
}
if ( m= = listBox1.Items.Count)
{
m= 0;
goto begin;
}
}
private void halo()
{
datagridView1.Rows.Add( a, listBox1.Items[m].ToString());
}
How can I put a code in the red part for delay issue and after that go back to begin:
Ryan AlfordPosted Jul 24, 2008, 9:13 AM
Arnold PetronaPosted Jul 24, 2008, 8:44 AM
Ok its working fine,
But the problem that I have now is that its hang. I want to make a delay of 10 sec before it goes back to the goto keyword .
What i'm doing is to make a life monitor system to get information and it wil be displayed in the datagridview.
Everytime it comes to its end it has to start back again in the first row. What i gonna use too is the datagridView.Rows.Clear() after the 10 sec.
do you have any idea for me
Techy WizardPosted Jul 23, 2008, 11:00 PM