Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8645075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:27:23+00:00 2026-06-12T12:27:23+00:00

Could somebody point me in the right direction on how to update a Gtk.TreeView

  • 0

Could somebody point me in the right direction on how to update a Gtk.TreeView after changing a CellRendererCombo in Gtk#?

Since the only example I found was in Python, I tried to port the example to C#, but without success so far.

The Python example is here: http://learngtk.org/pygtk-tutorial/cellrenderercombo.html

In the code below I am having difficulties with the method ComboChanged.

After changing the value in the combobox (by selecting a different value) and placing the focus outside of the combobox, the value does not change.

using System;
using Gtk;
using System.Collections.Generic;

public partial class MainWindow: Gtk.Window
{   
    public MainWindow (): base (Gtk.WindowType.Toplevel)
    {
        Build ();
        var tvComboBox = InitTreeViewWithComboBox ();
        var vbox = new Gtk.VBox ();
        vbox.PackStart (tvComboBox, true, true, 0);
        this.Add (vbox);
        this.ShowAll ();
    }       

    // adopted from http://learngtk.org/pygtk-tutorial/cellrenderercombo.html
    ListStore liststore_hardware;
    ListStore liststore_manufacturers;

    private TreeView InitTreeViewWithComboBox ()
    {
        liststore_manufacturers = new Gtk.ListStore(typeof (string));
        var manufacturers = new List<string> {"Sony", "LG", "Panasonic", "Toshiba", "Nokia", "Samsung"};
            foreach (var item in manufacturers) {
            liststore_manufacturers.AppendValues (item);
        }

        liststore_hardware = new Gtk.ListStore(typeof (string), typeof (string));
        liststore_hardware.AppendValues ("Television", "Samsung");
        liststore_hardware.AppendValues ("Mobile Phone", "LG");
        liststore_hardware.AppendValues ("DVD Player", "Sony");

        var treeview = new Gtk.TreeView ();
        treeview.Model = liststore_hardware;

        var column_text = new TreeViewColumn { Title = "Text" };
        var column_combo = new TreeViewColumn { Title = "Combo" };
        treeview.AppendColumn (column_text);
        treeview.AppendColumn (column_combo);

        var cellrenderer_text = new CellRendererText ();
        column_text.PackStart (cellrenderer_text, false);
        column_text.AddAttribute (cellrenderer_text, "text", 0);


        var cellrenderer_combo = new CellRendererCombo ();
        cellrenderer_combo.Editable = true;
        cellrenderer_combo.Model = liststore_manufacturers;
        cellrenderer_combo.TextColumn = 0;
        column_combo.PackStart (cellrenderer_combo, false);
        column_combo.AddAttribute (cellrenderer_combo, "text", 1);

        cellrenderer_combo.Edited += ComboChanged;

        return treeview;
    }

    void ComboChanged (object o, EditedArgs args)
    {
        // Not really sure what to do here....

        /*
        var crc = o as CellRendererCombo;
        TreeIter iter; // index within the combobox
        if (!crc.Model.GetIterFirst (out iter)) {
            return;
        }
        crc.Model.SetValue (iter, 0, args.NewText);
        liststore_hardware.SetValue (iterHardware, 1, args.NewText);
        */
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:27:25+00:00Added an answer on June 12, 2026 at 12:27 pm

    Going through the API a bit more I found the solution…:

    void ComboChanged (object o, EditedArgs args)
    {
        TreeSelection selection = treeview.Selection;
        TreeIter iter;
        if (!selection.GetSelected (out iter)) {
            return;
        }
        liststore_hardware.SetValue (iter, 1, args.NewText);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could somebody point me in the right direction of how I could read a
I wonder if somebody could point me in the right direction. We're currently looking
Could somebody please point me in the right direction for learning how to do
got a problem with dets:to_ets/2 Could somebody point me to an example online? Ive
Could somebody point me at or post an example of configuring a data source
Could somebody point out the necessary rights to do something like ALTER TABLE myTable
I'd be extremely grateful if somebody could help me, or point me in the
could somebody please take a look at this http://jsfiddle.net/bloodygeese/EzkFR/1/ My aim is to on
Could somebody explain what I'm doing wrong in attempting to insert a new UITableViewCell?
Could somebody please explain what this notation is in javascript? What is function(d) doing?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.