i have created a code for log. it is intended to provide the user with a recent
history of various events, primarily used in data-gathering applications where one
might be curious how a particular transaction completed. In this case, the log
need not be permanent nor saved to a file.

*i have to show the status of a running process in the same line of listbox.*

for this i used the below code inside the for loop.the problem is that each time it
enters for loop list box get updated and there is flickering in listbox.i need to
avoid this flickering and also i cant include any delay in for loop since
process shouldn't be delayed. here listbox1 is the list box.

namespace WindowsFormsApplication1
{


class sample
{
int frame_cnt=0;
int sl =listBox1.Items.Count;
for(int i=0;i<928;i++)
{
int percent = (int)(((double)(frame_cnt) /
(double)(928)) * 100) + 0;
listbox1.Items.Add(percent.ToString());
listBox1.Items.RemoveAt(sl-1);
frame_cnt++;
}
}
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

Try changing the listbox item value instead of using Add and RemoveAt.
e.g. listbox1.Items[sl-1] = percent.ToString();

Edited 5 Years Ago by nick.crane: n/a

Try changing the listbox item value instead of using Add and RemoveAt.
e.g. listbox1.Items[sl-1] = percent.ToString();

i tried this..but percent will go on repeating at sl-1 position,when it enters for loop repeatedly.

From your description of the problem and the pseudo-code you posted it is not clear what is causing the flicker.
Please give a more detailed snippet of your actual code.

This article has been dead for over six months. Start a new discussion instead.