Reputation: 39
Is it possible to display a watch among the listbox items ?? The point is that I can switch (if I select it in the listbox) between eg a clock and another string in the listbox and display it for example in some label in my form. As in the picture:
Every one of my attempts ends with the added time, but it does not refresh.
private void timer1_Tick(object sender, EventArgs e)
{
listBox3.Items[0] = DateTime.Now.ToString("HH:mm:ss");
}
private void clock()
{
}
Please Help.
Upvotes: 1
Views: 217
Reputation: 1215
This simplest solution would be to add listbox3.Refresh()
private void timer1_Tick(object sender, EventArgs e)
{
if (listBox3.Items.Count > 0)
{
listBox3.Items[0] = DateTime.Now.ToString("HH:mm:ss");
}
else
{
//Nothing in the list so add an item.
listBox3.Items.Add(DateTime.Now.ToString("HH:mm:ss"));
}
listBox3.Refresh();
}
Upvotes: 2