mail-archives/gtk-sharp-list/2009-June/009699.html

146 строки
6.3 KiB
HTML
Исходник Обычный вид История

2019-06-06 22:02:55 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] R: NodeView/TreeView. Image and Text into the same column
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20R%3A%20NodeView/TreeView.%20Image%20and%20Text%20into%20the%0A%09same%20column&In-Reply-To=%21%26%21AAAAAAAAAAAYAAAAAAAAABLQ3kS4O51Irls0cMgyxgXCgAAAEAAAALTpHum79nNIre15ePRZ5MsBAAAAAA%3D%3D%40creasoftware.net">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="009698.html">
<LINK REL="Next" HREF="009704.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] R: NodeView/TreeView. Image and Text into the same column</H1>
<B>Andy Selvig</B>
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20R%3A%20NodeView/TreeView.%20Image%20and%20Text%20into%20the%0A%09same%20column&In-Reply-To=%21%26%21AAAAAAAAAAAYAAAAAAAAABLQ3kS4O51Irls0cMgyxgXCgAAAEAAAALTpHum79nNIre15ePRZ5MsBAAAAAA%3D%3D%40creasoftware.net"
TITLE="[Gtk-sharp-list] R: NodeView/TreeView. Image and Text into the same column">ajselvig at gmail.com
</A><BR>
<I>Fri Jun 19 02:34:23 EDT 2009</I>
<P><UL>
<LI>Previous message: <A HREF="009698.html">[Gtk-sharp-list] NodeView/TreeView. Image and Text into the same column
</A></li>
<LI>Next message: <A HREF="009704.html">[Gtk-sharp-list] Gconf unsetting keys and walking the tree
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#9699">[ date ]</a>
<a href="thread.html#9699">[ thread ]</a>
<a href="subject.html#9699">[ subject ]</a>
<a href="author.html#9699">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Well, the easiest way is to declare your model as a TreeStore with two
strings (one for the name of the icon, one for the text):
var model = new Gtk.TreeStore(typeof(String), typeof(String));
The add rows with something like:
model.AppendValues(iconName, rowText);
Any icons that you show must be registered as a stock icon for this to work.
On Thu, Jun 18, 2009 at 6:57 PM, Aniello Di
Nardo&lt;<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">dinardo at creasoftware.net</A>&gt; wrote:
&gt;<i> Ok...
</I>&gt;<i>
</I>&gt;<i> But how to add a row or append values to the column?
</I>&gt;<i>
</I>&gt;<i> A.D.
</I>&gt;<i>
</I>&gt;<i> -----Messaggio originale-----
</I>&gt;<i> Da: Andy Selvig [mailto:<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">ajselvig at gmail.com</A>]
</I>&gt;<i> Inviato: venerd&#236; 19 giugno 2009 1.38
</I>&gt;<i> A: Aniello Di Nardo
</I>&gt;<i> Cc: <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">gtk-sharp-list at lists.ximian.com</A>
</I>&gt;<i> Oggetto: Re: [Gtk-sharp-list] NodeView/TreeView. Image and Text into the
</I>&gt;<i> same column
</I>&gt;<i>
</I>&gt;<i> Instead of making two columns, you want to pack the image and text
</I>&gt;<i> into one column like this:
</I>&gt;<i>
</I>&gt;<i> Gtk.TreeViewColumn column = new Gtk.TreeViewColumn();
</I>&gt;<i> var iconRenderer = new Gtk.CellRendererPixbuf();
</I>&gt;<i> column.PackStart(iconRenderer, false);
</I>&gt;<i> column.AddAttribute(iconRenderer, &quot;stock-id&quot;, 0);
</I>&gt;<i> var nameRenderer = new Gtk.CellRendererText();
</I>&gt;<i> column.PackStart(nameRenderer, true);
</I>&gt;<i> column.AddAttribute(nameRenderer, &quot;text&quot;, 1);
</I>&gt;<i> treeView.AppendColumn(column);
</I>&gt;<i>
</I>&gt;<i> On Thu, Jun 18, 2009 at 6:38 PM, Aniello Di
</I>&gt;<i> Nardo&lt;<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">dinardo at creasoftware.net</A>&gt; wrote:
</I>&gt;&gt;<i> Hi,
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> I&#8217;ll pack an image and text into the same column of a NodeView/TreeView
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> I&#8217;ve write the follow code, but it have two column&#8230; anyone can help me?
</I>&gt;&gt;<i> Thanks
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Gtk.TreeStore tsItems = new Gtk.TreeStore (typeof (Gdk.Pixbuf), typeof
</I>&gt;&gt;<i> (string));
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> trwMain.AppendColumn (&quot;Image&quot;, new Gtk.CellRendererPixbuf (), &quot;pixbuf&quot;,
</I>&gt;<i> 0);
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> trwMain.AppendColumn (&quot;Text&quot;, new Gtk.CellRendererText (), &quot;text&quot;, 1);
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> trwMain.HeadersVisible = false;
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Gtk.TreeIter iter = tsItems.AppendValues
</I>&gt;&gt;<i> (Gdk.Pixbuf.LoadFromResource(&quot;Tables.png&quot;), &quot;Tables&quot;);
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource(&quot;Names.png&quot;),
</I>&gt;&gt;<i> &quot;Names&quot;);
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource(&quot;Jobs.png&quot;),
</I>&gt;&gt;<i> &quot;Jobs&quot;);
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> trwMain.Model = tsItems;
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;<i> Gtk-sharp-list maillist &#160;- &#160;<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">Gtk-sharp-list at lists.ximian.com</A>
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</A>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;<i>
</I>&gt;<i>
</I></PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="009698.html">[Gtk-sharp-list] NodeView/TreeView. Image and Text into the same column
</A></li>
<LI>Next message: <A HREF="009704.html">[Gtk-sharp-list] Gconf unsetting keys and walking the tree
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#9699">[ date ]</a>
<a href="thread.html#9699">[ thread ]</a>
<a href="subject.html#9699">[ subject ]</a>
<a href="author.html#9699">[ 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>