NodeView/TreeView. Image and Text into the same column

View: New views
3 Messages — Rating Filter:   Alert me  

NodeView/TreeView. Image and Text into the same column

by Aniello Di Nardo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

 

I’ll pack an image and text into the same column of a NodeView/TreeView

 

I’ve write the follow code, but it have two column… anyone can help me? Thanks

 

Gtk.TreeStore tsItems = new Gtk.TreeStore (typeof (Gdk.Pixbuf), typeof (string));

trwMain.AppendColumn ("Image", new Gtk.CellRendererPixbuf (), "pixbuf", 0); 

trwMain.AppendColumn ("Text", new Gtk.CellRendererText (), "text", 1);

trwMain.HeadersVisible = false;

 

Gtk.TreeIter iter = tsItems.AppendValues (Gdk.Pixbuf.LoadFromResource("Tables.png"), "Tables");

tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource("Names.png"), "Names");

tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource("Jobs.png"), "Jobs");

 

trwMain.Model = tsItems;


_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Re: NodeView/TreeView. Image and Text into the same column

by Andy Selvig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Instead of making two columns, you want to pack the image and text
into one column like this:

Gtk.TreeViewColumn column = new Gtk.TreeViewColumn();
var iconRenderer = new Gtk.CellRendererPixbuf();
column.PackStart(iconRenderer, false);
column.AddAttribute(iconRenderer, "stock-id", 0);
var nameRenderer = new Gtk.CellRendererText();
column.PackStart(nameRenderer, true);
column.AddAttribute(nameRenderer, "text", 1);
treeView.AppendColumn(column);

On Thu, Jun 18, 2009 at 6:38 PM, Aniello Di
Nardo<dinardo@...> wrote:

> Hi,
>
>
>
> I’ll pack an image and text into the same column of a NodeView/TreeView
>
>
>
> I’ve write the follow code, but it have two column… anyone can help me?
> Thanks
>
>
>
> Gtk.TreeStore tsItems = new Gtk.TreeStore (typeof (Gdk.Pixbuf), typeof
> (string));
>
> trwMain.AppendColumn ("Image", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
>
> trwMain.AppendColumn ("Text", new Gtk.CellRendererText (), "text", 1);
>
> trwMain.HeadersVisible = false;
>
>
>
> Gtk.TreeIter iter = tsItems.AppendValues
> (Gdk.Pixbuf.LoadFromResource("Tables.png"), "Tables");
>
> tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource("Names.png"),
> "Names");
>
> tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource("Jobs.png"),
> "Jobs");
>
>
>
> trwMain.Model = tsItems;
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@...
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Parent Message unknown Re: R: NodeView/TreeView. Image and Text into the same column

by Andy Selvig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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<dinardo@...> wrote:

> Ok...
>
> But how to add a row or append values to the column?
>
> A.D.
>
> -----Messaggio originale-----
> Da: Andy Selvig [mailto:ajselvig@...]
> Inviato: venerdì 19 giugno 2009 1.38
> A: Aniello Di Nardo
> Cc: gtk-sharp-list@...
> Oggetto: Re: [Gtk-sharp-list] NodeView/TreeView. Image and Text into the
> same column
>
> Instead of making two columns, you want to pack the image and text
> into one column like this:
>
> Gtk.TreeViewColumn column = new Gtk.TreeViewColumn();
> var iconRenderer = new Gtk.CellRendererPixbuf();
> column.PackStart(iconRenderer, false);
> column.AddAttribute(iconRenderer, "stock-id", 0);
> var nameRenderer = new Gtk.CellRendererText();
> column.PackStart(nameRenderer, true);
> column.AddAttribute(nameRenderer, "text", 1);
> treeView.AppendColumn(column);
>
> On Thu, Jun 18, 2009 at 6:38 PM, Aniello Di
> Nardo<dinardo@...> wrote:
>> Hi,
>>
>>
>>
>> I’ll pack an image and text into the same column of a NodeView/TreeView
>>
>>
>>
>> I’ve write the follow code, but it have two column… anyone can help me?
>> Thanks
>>
>>
>>
>> Gtk.TreeStore tsItems = new Gtk.TreeStore (typeof (Gdk.Pixbuf), typeof
>> (string));
>>
>> trwMain.AppendColumn ("Image", new Gtk.CellRendererPixbuf (), "pixbuf",
> 0);
>>
>> trwMain.AppendColumn ("Text", new Gtk.CellRendererText (), "text", 1);
>>
>> trwMain.HeadersVisible = false;
>>
>>
>>
>> Gtk.TreeIter iter = tsItems.AppendValues
>> (Gdk.Pixbuf.LoadFromResource("Tables.png"), "Tables");
>>
>> tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource("Names.png"),
>> "Names");
>>
>> tsItems.AppendValues (iter, Gdk.Pixbuf.LoadFromResource("Jobs.png"),
>> "Jobs");
>>
>>
>>
>> trwMain.Model = tsItems;
>>
>> _______________________________________________
>> Gtk-sharp-list maillist  -  Gtk-sharp-list@...
>> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>>
>>
>
>
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list