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 #5397 is a reply to message #5394] Mon, 18 September 2006 14:26 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
nicomesas wrote on Mon, 18 September 2006 08:16

Hey

I have a ArrayCtrl in which a column represents money and I build it thus:

 theList.AddColumn("donativo").SetFormat("%2!nl").HeaderTab().SetAlign(ALIGN_RIGHT); 


The numerical columns see far better if they are aligned to right.

Nevertheless the alignment only affects to the header, not to the data in the column.

index.php?t=getfile&id=266&private=0

I believe that it must be possible that all a column is aligned, but encounter the function or the method not to do it.

Somebody can give an instructions to me.

Nico




Using Display.

In my commercial apps, I am using this one:

class DisplayMoney : public Display {
public:
	void Paint(Draw& w, const Rect& r, const Value& q,
		       Color ink, Color paper, dword style) const;

protected:
	Font   font;
	bool   red;

public:
	static DisplayMoney Normal;
	static DisplayMoney Bold;
	static DisplayMoney NormalRed;


	DisplayMoney& SetFont(Font _font)  { font = _font; return *this; }
	DisplayMoney& Red(bool b)          { red = b; return *this; }
	DisplayMoney& NoRed()              { return Red(false); }

	DisplayMoney(Font font = GuiFont(), bool red = true) : font(font), red(red) {}
};

void DisplayMoney::Paint(Draw& w, const Rect& r, const Value& q,
						 Color ink, Color paper, dword s) const {
	String text;
	if(!IsNull(q)) text = FormatMoney(q);
	int cx = GetSmartTextSize(w, text, font).cx;
	w.DrawRect(r, paper);
	DrawSmartText(w, r.left + r.Width() - cx, r.top, r.Width(), text, font,
		          double(q) < 0 ? (s & CURSOR) && (s & FOCUS) ? SLtRed: SRed : ink);
}



You can achieve pretty much any appearance using Display. To use it, make instance that outlives ArrayCtrl (static variable is enough) and assign it to the ArrayCtrl columns using SetDisplay.
 
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: Tue Jun 24 21:48:55 CEST 2025

Total time taken to generate the page: 0.07346 seconds