Click here to Skip to main content
15,885,855 members
Home / Discussions / C#
   

C#

 
Questionproblem with setup Pin
vijaylumar4-Jun-09 0:18
vijaylumar4-Jun-09 0:18 
AnswerRe: problem with setup Pin
Searril4-Jun-09 2:59
Searril4-Jun-09 2:59 
Questiontimers in listview [modified] Pin
snehanp3-Jun-09 23:37
snehanp3-Jun-09 23:37 
AnswerRe: timers in listview Pin
Christian Graus3-Jun-09 23:59
protectorChristian Graus3-Jun-09 23:59 
AnswerRe: timers in listview Pin
Rajesh R Subramanian4-Jun-09 0:00
professionalRajesh R Subramanian4-Jun-09 0:00 
AnswerRe: timers in listview Pin
Pete O'Hanlon4-Jun-09 0:11
mvePete O'Hanlon4-Jun-09 0:11 
GeneralRe: timers in listview Pin
snehanp4-Jun-09 0:43
snehanp4-Jun-09 0:43 
AnswerRe: timers in listview Pin
Pete O'Hanlon4-Jun-09 4:38
mvePete O'Hanlon4-Jun-09 4:38 
I knocked this quick sample together, and it should do what you want:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SimpleWinApp
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();

      _list.Add("Hello");
      _list.Add("There");
      _list.Add("What do you think");
      _list.Add("Hello");
      _list.Add("There");
      _list.Add("What do you think");
      _list.Add("Hello");
      _list.Add("There");
      _list.Add("What do you think");
      _list.Add("Hello");
      _list.Add("There");
      _list.Add("What do you think");
      _list.Add("Hello");
      _list.Add("There");
      _list.Add("What do you think");
      _list.Add("Hello");
      _list.Add("There");
      _list.Add("What do you think");

      int i = 0;
      foreach(string item in _list)
      {
        listView1.Items.Add(new ListViewItem(string.Format("{0}. {1}", i++, item)));
      }
    }

    private List<string> _list = new List<string>();
    private List<Timer> _timers = new List<Timer>();
    private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
    {
      // I'm going to add some code for the timer here.
      Timer timer = new Timer();
      timer.Interval = 1000;
      timer.Tag = e.Item;
      timer.Tick += new EventHandler(timer_Tick);
      timer.Start();
      _timers.Add(timer);
    }

    void timer_Tick(object sender, EventArgs e)
    {
      Timer timer = sender as Timer;
      if (timer != null)
      {
        timer.Stop();
        timer.Tick -= new EventHandler(timer_Tick);
        ListViewItem item = timer.Tag as ListViewItem;
        item.Remove();
        _timers.Remove(timer);
      }
    }
  }
}


"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



GeneralRe: timers in listview [modified] Pin
snehanp4-Jun-09 19:40
snehanp4-Jun-09 19:40 
GeneralRe: timers in listview Pin
Pete O'Hanlon5-Jun-09 1:15
mvePete O'Hanlon5-Jun-09 1:15 
Questionwindow MDI form Pin
Narsimha093-Jun-09 23:35
Narsimha093-Jun-09 23:35 
AnswerRe: window MDI form Pin
Rajdeep.NET3-Jun-09 23:48
Rajdeep.NET3-Jun-09 23:48 
GeneralRe: window MDI form Pin
Narsimha094-Jun-09 0:06
Narsimha094-Jun-09 0:06 
AnswerRe: window MDI form Pin
Mycroft Holmes4-Jun-09 0:58
professionalMycroft Holmes4-Jun-09 0:58 
QuestionHow to get a .Net Control of a web page in c# Pin
Yukivi3-Jun-09 23:20
Yukivi3-Jun-09 23:20 
AnswerRe: How to get a .Net Control of a web page in c# Pin
Henry Minute4-Jun-09 2:44
Henry Minute4-Jun-09 2:44 
QuestionZero's before number. Pin
Satish - Developer3-Jun-09 22:59
Satish - Developer3-Jun-09 22:59 
AnswerRe: Zero's before number. Pin
0x3c03-Jun-09 23:15
0x3c03-Jun-09 23:15 
AnswerRe: Zero's before number. Pin
Christian Graus3-Jun-09 23:17
protectorChristian Graus3-Jun-09 23:17 
AnswerRe: Zero's before number. Pin
Pete O'Hanlon3-Jun-09 23:22
mvePete O'Hanlon3-Jun-09 23:22 
AnswerRe: Zero's before number. Pin
CPallini4-Jun-09 0:54
mveCPallini4-Jun-09 0:54 
AnswerRe: Zero's before number. Pin
Lutosław4-Jun-09 1:46
Lutosław4-Jun-09 1:46 
AnswerRe: Zero's before number. Pin
Searril4-Jun-09 3:13
Searril4-Jun-09 3:13 
GeneralRe: Zero's before number. Pin
Lutosław6-Jun-09 1:50
Lutosław6-Jun-09 1:50 
QuestionCheck this out guys! Pin
Rajdeep.NET3-Jun-09 22:24
Rajdeep.NET3-Jun-09 22:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.