mail-archives/gtk-sharp-list/2005-June/006064.html

114 строки
4.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] Re: TreeViewColumn alignment
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Re%3A%20TreeViewColumn%20alignment&In-Reply-To=20050627141408.5BF8E1CFF58%40lists.ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="006079.html">
<LINK REL="Next" HREF="006068.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] Re: TreeViewColumn alignment</H1>
<B>Bryan Buchanan</B>
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Re%3A%20TreeViewColumn%20alignment&In-Reply-To=20050627141408.5BF8E1CFF58%40lists.ximian.com"
TITLE="[Gtk-sharp-list] Re: TreeViewColumn alignment">adslh3nu at tpg.com.au
</A><BR>
<I>Mon Jun 27 17:50:49 EDT 2005</I>
<P><UL>
<LI>Previous message: <A HREF="006079.html">[Gtk-sharp-list] GTK# unstable API docs
</A></li>
<LI>Next message: <A HREF="006068.html">[Gtk-sharp-list] cannot run mono app on XP using MS CLR
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#6064">[ date ]</a>
<a href="thread.html#6064">[ thread ]</a>
<a href="subject.html#6064">[ subject ]</a>
<a href="author.html#6064">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>
&gt;<i>
</I>&gt;<i> Message: 9
</I>&gt;<i> Date: Mon, 27 Jun 2005 19:21:56 +0530
</I>&gt;<i> From: Benoy George &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">mumsp at hotpop.com</A>&gt;
</I>&gt;<i> Subject: [Gtk-sharp-list] TreeViewColumn alignment
</I>&gt;<i> To: <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">gtk-sharp-list at lists.ximian.com</A>
</I>&gt;<i> Message-ID: &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">42C0047C.70408 at hotpop.com</A>&gt;
</I>&gt;<i> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
</I>&gt;<i>
</I>&gt;<i> Dear Friends,
</I>&gt;<i>
</I>&gt;<i> Please help me on how to right align a column in
</I>&gt;<i> Gtk.TreeViewColumn
</I>&gt;<i>
</I>&gt;<i> My current column definitions are
</I>&gt;<i>
</I>&gt;<i> col = new TreeViewColumn ();
</I>&gt;<i> colr = new CellRendererText ();
</I>&gt;<i> col.Title = &quot;Expense&quot;;
</I>&gt;<i> col.PackStart (colr, true);
</I>&gt;<i> col.AddAttribute (colr, &quot;text&quot;, 2);
</I>&gt;<i> col.Alignment = 0.0f;
</I>&gt;<i> col.Resizable = true;
</I>&gt;<i> tv.AppendColumn (col);
</I>&gt;<i>
</I>&gt;<i> I want to align above said column Expense to right-align
</I>&gt;<i> with two decimal point. I googled a lot, but no way to get
</I>&gt;<i> it done.
</I>&gt;<i>
</I>col.Alignment = 1.0f; // col title right aligned
colr.Xalign = 1.0f; // render data right aligned
Depending how your data is stored in the model you might also need
col.SetCellDataFunc(colr, new TreeCellDataFunc(ShowExpense));
and
void ShowExpense (TreeViewColumn tree_column,
CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
double x = (double) tree_model.GetValue(iter, 1);
((CellRendererText)cell).Text = String.Format(&quot;{0:N2}&quot;, x);
}
or similar.
Bryan
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="006079.html">[Gtk-sharp-list] GTK# unstable API docs
</A></li>
<LI>Next message: <A HREF="006068.html">[Gtk-sharp-list] cannot run mono app on XP using MS CLR
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#6064">[ date ]</a>
<a href="thread.html#6064">[ thread ]</a>
<a href="subject.html#6064">[ subject ]</a>
<a href="author.html#6064">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">More information about the Gtk-sharp-list
mailing list</a><br>
</body></html>