Click here to Skip to main content
15,929,812 members
Home / Discussions / C#
   

C#

 
GeneralPCSC using C# Pin
Member 129565029-Sep-04 17:01
Member 129565029-Sep-04 17:01 
GeneralA metronome app in C# Pin
NietzscheDisciple29-Sep-04 12:37
NietzscheDisciple29-Sep-04 12:37 
GeneralRe: A metronome app in C# Pin
Christian Graus29-Sep-04 13:27
protectorChristian Graus29-Sep-04 13:27 
GeneralRe: A metronome app in C# Pin
NietzscheDisciple29-Sep-04 13:38
NietzscheDisciple29-Sep-04 13:38 
GeneralRe: A metronome app in C# Pin
Stefan Troschuetz29-Sep-04 22:05
Stefan Troschuetz29-Sep-04 22:05 
Generallooking for .Net class lib to edit mp3 and ogg tags Pin
spazzman29-Sep-04 12:37
spazzman29-Sep-04 12:37 
GeneralRe: looking for .Net class lib to edit mp3 and ogg tags Pin
Christian Graus29-Sep-04 13:28
protectorChristian Graus29-Sep-04 13:28 
QuestionA timer problem? Pin
cemlouis29-Sep-04 11:14
cemlouis29-Sep-04 11:14 
Hi,

I have a listbox with three values on it and a button on my form. When I pressed the button the listbox have to select the next item after 2 seconds. Then select the next one after 2 seconds... And so on... Here is my unworking below code:

Anyhelp would be greatly appreciated...
Thank you indeed...
Cem Louis

<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Timers;<br />
using System.Threading;<br />
<br />
namespace WindowsApplication14<br />
{<br />
	/// <summary><br />
	/// Summary description for Form1.<br />
	/// </summary><br />
	public class Form1 : System.Windows.Forms.Form<br />
	{<br />
		private System.Windows.Forms.ListBox listBox1;<br />
		private System.Windows.Forms.Button button1;<br />
		private System.Timers.Timer timerClock = new System.Timers.Timer();<br />
		/// <summary><br />
		/// Required designer variable.<br />
		/// </summary><br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public Form1()<br />
		{<br />
			//<br />
			// Required for Windows Form Designer support<br />
			//<br />
			InitializeComponent();<br />
<br />
			//<br />
			// TODO: Add any constructor code after InitializeComponent call<br />
			//<br />
		}<br />
<br />
		public void InitializeTimer()<br />
		{<br />
			this.timerClock.Elapsed += new ElapsedEventHandler(OnTimer);<br />
			this.timerClock.Interval = 2000;<br />
			this.timerClock.Enabled = true;<br />
		}<br />
<br />
		/// <summary><br />
		/// Clean up any resources being used.<br />
		/// </summary><br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			if( disposing )<br />
			{<br />
				if (components != null) <br />
				{<br />
					components.Dispose();<br />
				}<br />
			}<br />
			base.Dispose( disposing );<br />
		}<br />
<br />
		#region Windows Form Designer generated code<br />
		/// <summary><br />
		/// Required method for Designer support - do not modify<br />
		/// the contents of this method with the code editor.<br />
		/// </summary><br />
		private void InitializeComponent()<br />
		{<br />
			this.listBox1 = new System.Windows.Forms.ListBox();<br />
			this.button1 = new System.Windows.Forms.Button();<br />
			this.SuspendLayout();<br />
			// <br />
			// listBox1<br />
			// <br />
			this.listBox1.Location = new System.Drawing.Point(8, 8);<br />
			this.listBox1.Name = "listBox1";<br />
			this.listBox1.Size = new System.Drawing.Size(120, 95);<br />
			this.listBox1.TabIndex = 0;<br />
			// <br />
			// button1<br />
			// <br />
			this.button1.Location = new System.Drawing.Point(8, 112);<br />
			this.button1.Name = "button1";<br />
			this.button1.Size = new System.Drawing.Size(120, 23);<br />
			this.button1.TabIndex = 1;<br />
			this.button1.Text = "Run";<br />
			this.button1.Click += new System.EventHandler(this.button1_Click);<br />
			// <br />
			// Form1<br />
			// <br />
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
			this.ClientSize = new System.Drawing.Size(136, 142);<br />
			this.Controls.Add(this.button1);<br />
			this.Controls.Add(this.listBox1);<br />
			this.Name = "Form1";<br />
			this.Text = "Form1";<br />
			this.Load += new System.EventHandler(this.Form1_Load);<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
		/// <summary><br />
		/// The main entry point for the application.<br />
		/// </summary><br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			Application.Run(new Form1());<br />
		}<br />
<br />
		private void Form1_Load(object sender, System.EventArgs e)<br />
		{<br />
			listBox1.Items.Add("Arthur");<br />
			listBox1.Items.Add("Alex");<br />
			listBox1.Items.Add("Amie");<br />
			listBox1.Update();<br />
		}<br />
<br />
		private void OnTimer(object source, ElapsedEventArgs e)<br />
		{<br />
			this.nextvalue();<br />
		}<br />
<br />
		private void button1_Click(object sender, System.EventArgs e)<br />
		{<br />
			this.nextvalue();<br />
		}<br />
<br />
		private void nextvalue()<br />
		{<br />
			for(int i = 0;i<listBox1.Items.Count;i++)<br />
			{<br />
				listBox1.SetSelected(listBox1.Items.Count-i,true);<br />
			}<br />

AnswerRe: A timer problem? Pin
smithriver29-Sep-04 11:47
smithriver29-Sep-04 11:47 
GeneralRe: A timer problem? Pin
cemlouis29-Sep-04 14:12
cemlouis29-Sep-04 14:12 
GeneralRe: A timer problem? Pin
smithriver30-Sep-04 5:26
smithriver30-Sep-04 5:26 
GeneralRe: A timer problem? Pin
smithriver11-Oct-04 6:24
smithriver11-Oct-04 6:24 
GeneralEmbed and play an AVI file Pin
smithriver29-Sep-04 11:12
smithriver29-Sep-04 11:12 
GeneralGetting CPU Usage of a particular process Pin
filburt129-Sep-04 10:46
filburt129-Sep-04 10:46 
GeneralRe: Getting CPU Usage of a particular process Pin
leppie30-Sep-04 2:48
leppie30-Sep-04 2:48 
GeneralRe: Getting CPU Usage of a particular process Pin
Anonymous30-Sep-04 6:13
Anonymous30-Sep-04 6:13 
GeneralTab Control on .NET CF Pin
Member 59042329-Sep-04 9:06
Member 59042329-Sep-04 9:06 
GeneralRe: Tab Control on .NET CF Pin
Christian Graus29-Sep-04 13:30
protectorChristian Graus29-Sep-04 13:30 
Generaltoolboards Pin
Dantubby29-Sep-04 9:06
Dantubby29-Sep-04 9:06 
GeneralRe: toolboards Pin
Nick Parker29-Sep-04 9:25
protectorNick Parker29-Sep-04 9:25 
GeneralRe: toolboards Pin
Dantubby29-Sep-04 9:34
Dantubby29-Sep-04 9:34 
Generalsoap wse Pin
jeffjf29-Sep-04 7:17
jeffjf29-Sep-04 7:17 
GeneralRe: soap wse Pin
Heath Stewart29-Sep-04 7:49
protectorHeath Stewart29-Sep-04 7:49 
GeneralRe: soap wse Pin
jeffjf30-Sep-04 0:18
jeffjf30-Sep-04 0:18 
GeneralRe: soap wse Pin
Heath Stewart30-Sep-04 5:30
protectorHeath Stewart30-Sep-04 5:30 

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.