Click here to Skip to main content
15,896,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: DataGird Can U help Me Pin
Praveen Nayak23-Feb-06 19:18
Praveen Nayak23-Feb-06 19:18 
GeneralRe: DataGird Can U help Me Pin
AnhTin23-Feb-06 20:23
AnhTin23-Feb-06 20:23 
GeneralRe: DataGird Can U help Me Pin
Maqsood Ahmed23-Feb-06 22:34
Maqsood Ahmed23-Feb-06 22:34 
Questionretrieving the installion path during installion wizard Pin
2hdass23-Feb-06 13:26
2hdass23-Feb-06 13:26 
AnswerRe: retrieving the installion path during installion wizard Pin
veeru_syd27-Feb-06 12:44
veeru_syd27-Feb-06 12:44 
QuestionHandle Word prompts during Automation Pin
Guinness4Strength23-Feb-06 12:30
Guinness4Strength23-Feb-06 12:30 
Questiontyped dataset Pin
fmardani23-Feb-06 11:02
fmardani23-Feb-06 11:02 
QuestionListBox Invalidate issue Pin
Clarke7623-Feb-06 9:24
Clarke7623-Feb-06 9:24 
I have a listbox inwhich all items in that control are check every 30mins. If during that period time it finds an error, that same timer causes the text in the listbox to blink. The issue I'm having is, that this color change is going on every second and causing a blinking on the control. Now I've read articles on double buffering to fix this issue, but have yet to find a single one that works. The best I've gotten it was that one item, other than the item(s) that are supose to blink, will blink every second which isn't as bad as all items but is very very annoying. Here is the code....any ideas?

This is how I draw the text:
<br />
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)<br />
		{<br />
			e.DrawBackground(); <br />
			e.DrawFocusRectangle();<br />
			if( listBox1.Items[ e.Index ] is Server )<br />
			{<br />
				Server server = (Server)listBox1.Items[e.Index];<br />
<br />
				if( server.Error )<br />
				{<br />
					if( blinking )<br />
						e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Red,<br />
							new Point(e.Bounds.X,e.Bounds.Y));<br />
					else<br />
						e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Black,<br />
							new Point(e.Bounds.X,e.Bounds.Y));<br />
				}<br />
				else<br />
					e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Black,<br />
						new Point(e.Bounds.X,e.Bounds.Y));<br />
			}<br />
			else				<br />
				e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Black,<br />
				new Point(e.Bounds.X,e.Bounds.Y));<br />
		}<br />


The timer:
<br />
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)<br />
		{<br />
			timer1.Stop();<br />
			bool blink = false;<br />
			/*if( click % 3600 == 0 || click == 0 )<br />
			{<br />
				foreach( Object item in listBox1.Items )<br />
				{<br />
					if( item is Server )<br />
					{<br />
						Server server = (Server)item;<br />
						Ping ping = new Ping();<br />
						PingInfo info = ping.PingHost( server.Name );					<br />
						server.PingResponse = info.ResponceTime();<br />
						server.TimeOut = info.TimeOut();<br />
<br />
						if( server.PingResponse > 2 || server.TimeOut )<br />
							server.Error = true;<br />
						else<br />
							server.Error = false;<br />
					}<br />
				}<br />
			}*/<br />
			for( int i=0; i<listBox1.Items.Count; i++ )<br />
			{<br />
				if( listBox1.Items[i] is Server )<br />
				{<br />
					Server server =  (Server)listBox1.Items[i];<br />
					if( server.Error )<br />
					{<br />
						if( blinking )<br />
						{<br />
							blinking = false;<br />
						}<br />
						else<br />
							blinking = true;<br />
<br />
						if( !blink )<br />
							blink = true;<br />
						listBox1.Invalidate();<br />
                                                <br />
					}<br />
				}<br />
			}<br />
<br />
			click++;<br />
			timer1.Start();<br />


Control Properties
<br />
this.DrawMode = DrawMode.OwnerDrawFixed;<br />
			this.SetStyle(<br />
				ControlStyles.AllPaintingInWmPaint |<br />
				ControlStyles.DoubleBuffer |<br />
				ControlStyles.Opaque , true );	<br />


Adding ControlStyles.UserPaint causes the control to go completly black.


Any help would be great!
Thanks
QuestionC# key/mouse detection Pin
weizur123-Feb-06 9:11
weizur123-Feb-06 9:11 
AnswerRe: C# key/mouse detection Pin
Robin Panther23-Feb-06 12:21
Robin Panther23-Feb-06 12:21 
GeneralRe: C# key/mouse detection Pin
weizur123-Feb-06 12:44
weizur123-Feb-06 12:44 
GeneralRe: C# key/mouse detection Pin
Allah On Acid23-Feb-06 15:28
Allah On Acid23-Feb-06 15:28 
GeneralRe: C# key/mouse detection Pin
weizur123-Feb-06 20:49
weizur123-Feb-06 20:49 
GeneralRe: C# key/mouse detection Pin
Allah On Acid24-Feb-06 4:24
Allah On Acid24-Feb-06 4:24 
GeneralRe: C# key/mouse detection Pin
Robin Panther23-Feb-06 21:45
Robin Panther23-Feb-06 21:45 
QuestionGDI TextOut and System.OutOfMemoryException Pin
Draders2323-Feb-06 8:10
Draders2323-Feb-06 8:10 
Questionc# desktop database application Pin
stefan1223-Feb-06 7:40
stefan1223-Feb-06 7:40 
AnswerRe: c# desktop database application Pin
Sean8923-Feb-06 8:48
Sean8923-Feb-06 8:48 
GeneralRe: c# desktop database application Pin
stefan1223-Feb-06 9:19
stefan1223-Feb-06 9:19 
GeneralRe: c# desktop database application Pin
Sean8923-Feb-06 9:33
Sean8923-Feb-06 9:33 
AnswerRe: c# desktop database application Pin
André Ziegler24-Feb-06 1:54
André Ziegler24-Feb-06 1:54 
QuestionConstructors at design time Pin
SteelIXB23-Feb-06 7:31
SteelIXB23-Feb-06 7:31 
AnswerRe: Constructors at design time Pin
SteelIXB23-Feb-06 8:45
SteelIXB23-Feb-06 8:45 
GeneralRe: Constructors at design time Pin
Dan Neely23-Feb-06 9:04
Dan Neely23-Feb-06 9:04 
QuestionReading CSV Pin
john3423-Feb-06 7:26
john3423-Feb-06 7:26 

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.