Need to format data in bound textbox

G

Guest

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.
 
K

Klaus Löffelmann

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
 
B

BB

These are both good ideas...thanks.
-----Original Message-----
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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top