By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

ConvertEventHandler not converting on first record

P: n/a

I have a win forms project, for simplicity's sake, lets say that I
have a dataset and a textbox that is bound to a numeric column in the
dataset. I also specified a ConvertEventHandler to format the number
in the textbox.

The problem I have is when I run the app, the very first record the
textbox displays is never formatted correctly (the ConvertEventHandler
is never called, I checked). Navigating to the next and subsequent
records it works fine, the number is formatted as per my procedure.

Is there any reason for this behavior? Why is it that only the first
record is affected and subsequent record navigation works fine?
......databinding code:
private void DataBindControls()
textBox1.DataBindings.Add("Text", this.myDataSet,
textBox1.DataBindings["Text"].Format += new

......formatting code:
private void ToDoubleString(object sender, ConvertEventArgs e)
if (e.Value.ToString() == string.Empty)
e.Value = DBNull.Value; // Don't format nulls.
e.Value = ((double)e.Value).ToString("#,##0.0######");

Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.