Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » how align a column?
Re: how align a column? [message #10532 is a reply to message #10507] Sat, 14 July 2007 09:36 Go to previous messageGo to previous message
kfeng is currently offline  kfeng
Messages: 18
Registered: July 2007
Location: Tokyo, Japan
Promising Member
luzr wrote on Fri, 13 July 2007 00:55

kfeng wrote on Thu, 12 July 2007 17:54


Another question: is there a standard format for displaying %d or %f like this:

$58,782,398.23

with commas?



No.

Quote:


If not, maybe you can guide me to where I can add code for this feature with any suggestions on the protocol. If you do, I can code it up and submit it for addition to the code base.



But you in fact do not need to fix uppsrc code to get it: Format is extensible, you can add your own formatters quite easily, see RegisterFormatter (it is even documented Wink.

In the same time, would be nice to have it in Core too later, but for that purpose it would best be done configurable via translations... (means it should be described by some string literal, just like date or time).

Mirek



Hi Mirek,

Internationalization is a little beyond me for now, so I will just submit a little snipplet for others to use/incorporate into their code:
String CommaFormatter(const Formatting& f)
{
  int    commaSpacing = 3;  // fix at 3 for now
  String res          = Format( "%" + f.format + "f", f.arg );  // replace our format with "f"
  int    period       = res.Find( '.' );
  int    idx          = (period<0) ? res.GetLength() : period;
  while( (idx-=commaSpacing)>0 )
    res.Insert( idx, ',' );	
  return res;
}

// Test it
RegisterNumberFormatter("C",  CommaFormatter);
String test = Format( "%.2C", 35829123.4253 );
// 35,829,123.43


- Ken
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GridCtrl and non contigous cells
Next Topic: Can I center an Option control in an ArrayCtrl column?
Goto Forum:
  


Current Time: Wed Jun 25 02:30:07 CEST 2025

Total time taken to generate the page: 0.03938 seconds