|
Evening all !
I've created a new timer in a form's constructor to make a button on the form flash.
For some reason the program is stepping through the code for the timer tick ONCE and thats it ?
Would appreciate if someone could take a look at it and tell me whats wrong, it's porbably something trivial and i've just been looking at the code too long now !
Thanks in advance
Neil
public Form1()
{
InitializeComponent();
buttonTimer = new Timer();
buttonTimer.Tick += new EventHandler(button_Tick);
buttonTimer.Interval = (50);
populate.BackColor = Color.Black;
populate.ForeColor = Color.Orange;
buttonTimer.Start();
}
void button_Tick(object sender, EventArgs e)
{
if (populate.BackColor == Color.Orange)
{
populate.BackColor = Color.Black;
populate.ForeColor = Color.Orange;
}
if (populate.BackColor == Color.Black)
{
populate.BackColor = Color.Orange;
populate.ForeColor = Color.Black;
}
}
}
|
|
|
|
|
Instead of this:
buttonTimer.Tick += new EventHandler(button_Tick);
Try this:
buttonTimer.Elapsed += new EventHandler(button_Elapsed);
Don't know if it makes any difference, but it's worth a try.
|
|
|
|
|
That's for a System.Timer, not a System.Windows.Forms.Timer. The Elapsed event is run in a separate thread, so that can't be used to update controls in the form.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
I had this problem, the cause is that you are setting your event in the load method, which exits so the event is no longer registered.
buttonTimer.Tick += new EventHandler(button_Tick);
Put that in another method so that it is set again.
The way I explained this is probably not the most tech savvy way, but I'm 100% sure that your event gets triggered only once because the form load method quits after your form is loaded.
|
|
|
|
|
That makes no sense at all.
|
|
|
|
|
Looks like you are testing the Color for Orange and if so, setting it to Black.
Right after that you test for Black and set it back to Orange.
After the ForeColor = Color.Orange, add a return ;.
|
|
|
|
|
Bingo! This is just what I was thinking.
|
|
|
|
|
Better yet, use an else:
if (populate.BackColor == Color.Orange) {
populate.BackColor = Color.Black;
populate.ForeColor = Color.Orange;
} else {
populate.BackColor = Color.Orange;
populate.ForeColor = Color.Black;
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
it isn't stepping through once - stick a breakpoint in to prove that.
it just has no effect the 2nd and subsequent times...
replace
if (populate.BackColor == Color.Black)
with
"else"
and all will be well.
Inidentally, if I were you, I would put
((Timer)sender).Stop();
at the start of yor buttin_Click event handler, and
((Timer)sender).Start();
at the end.
This stops the timer triggering while the code is still executing - and helps when you are debugging too!
If I knew then what I know today, then I'd know the same now as I did then - then what would be the point?
.\\axxx
(That's an 'M')
|
|
|
|
|
hi all,
i have a xml files which the the data is in attributes like this:
<detail>
<record>
<field name='field1' value='value1'/>
<field name='field2' value='value2'/>
<field name='field3' value='value3'/>
<field name='field4' value='value4'/>
</record>
<record>
<field name='field1' value='value1'/>
<field name='field2' value='value2'/>
<field name='field3' value='value3'/>
<field name='field4' value='value4'/>
</record>
</detail>
since datatables read only xml that are formated without attributes how could i load this into a datatable?
|
|
|
|
|
Seems like you'll create code to parse/load it into a table or use an XSL transform and then load it via ReadXml.
|
|
|
|
|
Any idea of a xsl/xps generator for attributed XML?
|
|
|
|
|
Sorry, you'll have to do some googling. I don't know of any.
|
|
|
|
|
I want to read some files over a network from over 200 pcs. I want to read from 1 pc and if ReadTimeOut has been reached, I want to try a different pc because I do not want to wait forever if I can not read from a certain Pc. How can I do this? FileStream has a property to set the ReadTimeOut but how do I know when this timeout is reached so I can do something else, and try again later.
|
|
|
|
|
|
|
I was actually reading about BeginRead() and IAsyncResult and that is why I asked the question. But the thing I am confused about is would I call BeginRead() on something like 10 different pcs and when each returns it will invoke the delegate in my code? Or do I have to do it differently? Also, can I store the data for all these files read in DataTable objects--1 for each pc--or is that too much resources? The files are not big but just about 50 lines.
|
|
|
|
|
Hi,
I want Auto complete with textbox with multiple columns.
I've seen alredy Auto complete combobox with multiple columns.
But I need it in text box.
When user enter a product it should popup autocomplete window and its related information. eg: Product Rate,Stock etc.
Can anyone help me Please? i am using c#.net 2008 Windows Application.
|
|
|
|
|
|
Mika Wendelius wrote: Did you serach the articles: http://www.codeproject.com/info/search.aspx?artkw=Auto+complete+textbox+&sbo=kw[^]
For example http://www.codeproject.com/KB/cs/AutoCompleteTextBox.aspx[^] looks promising.
Amazing, 5'ed.
|
|
|
|
|
Hi,
Thank you for your reply.
But i want more than one column in Auto Complete Text box.
Thank you.
|
|
|
|
|
Intellisense stopped working for anything in my App_Code folder - my class files and what not. Works just fine for regular code-behind pages.
Any ideas?
|
|
|
|
|
I've seen this happen while Debugging if you have it set to Release mode instead of Debug mode (no debug symbols created for Release exe).
Keep It Simple Stupid! (KISS)
|
|
|
|
|
By the way, I think my Texans will take care of business up there in the 'frozen tundra' this weekend .
Keep It Simple Stupid! (KISS)
|
|
|
|