Hai to all,
I have done one task but it is not proper, just you guys fine tune my task.
I am using Windows Application with C# Languvage.
I have one Listview (Listview contain 5 Items), 2 Buttons (Play, Pause)
Aim : My goal is when I click the Play Button the listview top first item will select and the selection will moves one by one of some particular timing interval.
I have done: What I have done is, Listview item will select using forloop, it will moves one by one for particular timing interval using thread.sleep(3000) method , and the same time, From listview selection change event I have to select that particular item.
Error :
1. But when I start Play Button listview items will select and moves one by one, But I am using messagebox (See coding below) in listview selection change event, For that only it will select one by one, Without messagebox it won't select one by one.
(I need without using messagebox it will select one by one)
2. Secondly, When I Click the Pause Button the process won't stop. It is continuous running.
(I need to Stop the process when I click the pause Button)
My Coding:
------------------------------- Coding Starts --------------------------------------
// Play Button Click Event
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0, j = 0; i < listView1.Items.Count && j < listView1.Items.Count; j++)
{
if (j != 0)
{
listView1.Items[j - 1].Selected = false;
}
listView1.Items[j].Selected = true;
Thread.Sleep(3000);
if (j == listView1.Items.Count - 1)
{
listView1.Items[j].Selected = false;
j = -1;
}
}
}
//List view Selection index Change coding
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
listView1.Select();
MessageBox.Show(listView1.SelectedIndices[0].ToString());
}
}
//Pause Button Click Event
private void button2_Click(object sender, EventArgs e)
{
}
--------------------------- Coding Finished ---------------------------
I Hope Every one Understand what I am asking, If any one not able to understood i am ready to explain once again. But I need the Solution.
Regards,
Vasanth