윈도우 폼에서 동적으로 타이머 컨트롤을 만들 때 어떻게 타이머 컨트롤의 개체를 구별 할 수 있습니까? 타이머 컨트롤은 n 숫자입니다 ... 이것은 런타임시 deisde입니다. 와 타이머 컨트롤을 대체 할타이머 컨트롤의 인스턴스는 무엇입니까? 창문 양식?
class MainForm(Form)
{
Dictionary<string, Timer> timers;
public MainForm()
{
InitializeComponents();
timers = new Dictionary<string, Timer>();
}
public Timer AddTimer(string name, int interval, bool enabled, int id)
{
Timer t = new Timer();
t.Interval = interval;
t.Enabled = enabled;
t.Tag = id;
t.Ticks += new EventHandler(TimerEventProcessor);
timers.add(name, t);
return t;
}
public Timer GetTimer(string name)
{
if (timers.ContainsKey(name))
{
return timers[name];
}
else
{
return null;
}
}
private static void TimerEventProcessor(Object myObject,
EventArgs myEventArgs) {
Timer sourceTimer = myObject as Timer;
}
}
}
감사합니다. Mr. Icfseth 내가 확인하고 알려 드리겠습니다. –
Mr. Icfseth, 쓰고 있습니다 ... Timer t = new Timer(); t.Name = 이름; 내가 t.Name 오류가 발생했습니다 그런 속성이 없습니다 –
당신은 절대적으로 옳았습니다. 그냥 그 줄을 버리십시오. –