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

Need to format data in bound textbox

P: n/a
Hi all,

I need to format screen output for a textbox that's bound
to a datasource. I know how to format the data in a
plain old string, but in this case I'm not sure where
to "sneak" in there to do the formatting.

For example, textbox txtAcctBalance is bound to a
currency field in my dataset, and when the value shows up
on the screen I want it formatted as currency ("C").

I've tried doing this on the TextChanged event of the
textbox, which has potential, but one problem is that as
soon as I reformat the text it fires the TextChanged
event again. I guess I can turn off the handler
temporarily, but all this seems way harder than it should
be.

Any ideas?

Thanks,

BB

P.S. I can do this on a bound datagrid, because there's
a "format" specifier on the grid column. I just can't
find the same thing for the stand-alone textbox.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
BB,

honestly, I never tried it, but maybe you could check the sender object of
the event, to differentiate between the sources of the it.
If that doesn't work, implement a bool-member in the form, signaling, if you
or the database changed the text. Only react to the event, if the flag is
not set, and set it, befor you change the text.

Klaus

<an*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:00****************************@phx.gbl...
Hi all,

I need to format screen output for a textbox that's bound
to a datasource. I know how to format the data in a
plain old string, but in this case I'm not sure where
to "sneak" in there to do the formatting.

For example, textbox txtAcctBalance is bound to a
currency field in my dataset, and when the value shows up
on the screen I want it formatted as currency ("C").

I've tried doing this on the TextChanged event of the
textbox, which has potential, but one problem is that as
soon as I reformat the text it fires the TextChanged
event again. I guess I can turn off the handler
temporarily, but all this seems way harder than it should
be.

Any ideas?

Thanks,

BB

P.S. I can do this on a bound datagrid, because there's
a "format" specifier on the grid column. I just can't
find the same thing for the stand-alone textbox.

Nov 20 '05 #2

P: n/a
BB
These are both good ideas...thanks.
-----Original Message-----
BB,

honestly, I never tried it, but maybe you could check the sender object ofthe event, to differentiate between the sources of the it.If that doesn't work, implement a bool-member in the form, signaling, if youor the database changed the text. Only react to the event, if the flag isnot set, and set it, befor you change the text.

Klaus

<an*******@discussions.microsoft.com> schrieb im Newsbeitragnews:00****************************@phx.gbl...
Hi all,

I need to format screen output for a textbox that's bound to a datasource. I know how to format the data in a
plain old string, but in this case I'm not sure where
to "sneak" in there to do the formatting.

For example, textbox txtAcctBalance is bound to a
currency field in my dataset, and when the value shows up on the screen I want it formatted as currency ("C").

I've tried doing this on the TextChanged event of the
textbox, which has potential, but one problem is that as soon as I reformat the text it fires the TextChanged
event again. I guess I can turn off the handler
temporarily, but all this seems way harder than it should be.

Any ideas?

Thanks,

BB

P.S. I can do this on a bound datagrid, because there's a "format" specifier on the grid column. I just can't
find the same thing for the stand-alone textbox.

.

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.