Having trouble getting IconView to work

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

Having trouble getting IconView to work

by vbtricks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Salut,

I am trying to initialize an IconView. In the MonoDevelop designer I added the IconView iconView1 to the window and did not modify any properties. In the code-behind file in the constructor I'm trying to initialize the ListStore:

private Gtk.ListStore store;

public MainWindow(): base(Gtk.WindowType.Toplevel)
{
  Build();
 
  this.store = new ListStore(typeof(string), typeof(string), typeof(string));
  this.store.AppendValues("1", "2", "3");
  this.iconview1.Model = this.store;
}

though, the IconView does not display anything. How to get a three columned IconView to work?


Thanks in advance,

Stefan

Re: Having trouble getting IconView to work

by countcb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

vbtricks wrote:
Salut,

I am trying to initialize an IconView. In the MonoDevelop designer I added the IconView iconView1 to the window and did not modify any properties. In the code-behind file in the constructor I'm trying to initialize the ListStore:

private Gtk.ListStore store;

public MainWindow(): base(Gtk.WindowType.Toplevel)
{
  Build();
 
  this.store = new ListStore(typeof(string), typeof(string), typeof(string));
  this.store.AppendValues("1", "2", "3");
  this.iconview1.Model = this.store;
}

though, the IconView does not display anything. How to get a three columned IconView to work?


Thanks in advance,

Stefan
At First: IconView is used to Display Icons (Images). So your model (ListStore) should contain some Images.

  this.store = new ListStore(typeof(string), typeof (Gdk.Pixbuf), typeof(string));
  // append some values here


Then you have to tell the IconView in which colums of your model it can find the needed information.
MarkupColumn int. Contains the number of the model column containing markup information to be displayed.
PixbufColumn int. Contains the number of the model column containing the pixbufs which are displayed

For Example:
this.iconview1.MarkupColumn = 0; // the info string
this.iconview1.PixbufColumn = 1; // this has to the column with the Gdk.Pixbuf

Then your iconview should display the string in column 0 as an info, and the Pixbuf in Column 1 as the Icon.

Hope that helps.