On 07/14/2010 03:54 PM, John wrote: > On Wednesday 14 July 2010 03:27:18 pm Jeff Johnson wrote: > >> I have dtextboxes where numbers with 2 decimals are entered and then >> values in other dtextboxes are programatically updated. Some times they >> have 1 zero and sometimes 3. Is there a way to display a number with no >> decimals or 2 only? >> >> TIA >> > You have not provided enough info to provide which of the solutions you may > need from below so I listed a few. > > 1. If you just need to display a value then something like this will work: > object.Value = "%.2f" % (float(self.total_sum.Value), ) > > The above will format the Value to something like '123.00' > > 2. You could subclass the textbox creating your own floatTextBox(). > > 3. Try using dMaskedTextBox(). > You need to read the formating options. > > 4. You could use the "DynamicValue =" property of dTextBox and provide a > function that returns the correct format. > > dabo.ui.dTextBox(self, DataSource = 'someBizObj', DataField = 'someDataField', > DynamicValue = self.myFloatMethod) > > def myFloatMethod(self): > return "%.2f" % (float(self.total_sum.Value), ) > #or whatever is the right way to get your result > > 5. Use a dabo.ui.dSpinner. > > So it depends on your needs as to which one you pick. I have used all of the > above for different reasons. > > > Johnf > > > > Thanks John! I've used #4 to accomplish quite a few things and seems to work quite well.
Thanks, -- Jeff --------------- Jeff Johnson [email protected] (623) 582-0323 www.san-dc.com _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
