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

  • Home
  • SEARCH
  • 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 439839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:48:48+00:00 2026-05-12T20:48:48+00:00

All I can figure out is something to do with the ComboBox.GetEnumerator or something

  • 0

All I can figure out is something to do with the ComboBox.GetEnumerator or something like that.

I would like to do something like:

System.Collections.IEnumerator e = this.task_difficulty_combobox.GetEnumerator();
while (e.MoveNext())
{
    if (e.ToString() == this.task.Difficulty.ToString())
    {
        Gtk.TreeIter i = (Gtk.TreeIter)e.Current;
        this.task_difficulty_combobox.SetActiveIter(i);
        break;
    }
}

However, This doesn’t work.

  • 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-05-12T20:48:49+00:00Added an answer on May 12, 2026 at 8:48 pm

    The reason your code doesn’t work is that the “items in the combobox” are actually the cell renderers packed into it for displaying columns of data. To get at the actual data, you need the TreeModel object.

    If you really must select based only on what’s in the combo, here’s how you can do it:

    string[] values = new string[]{"one", "two", "three"};
    var combo = new ComboBox(values);
    
    Gtk.TreeIter iter;
    combo.Model.GetIterFirst (out iter);
    do {
      GLib.Value thisRow = new GLib.Value ();
      combo.Model.GetValue (iter, 0, ref thisRow);
      if ((thisRow.Val as string).Equals("two")) {
        combo.SetActiveIter (iter);
        break;
      }
    } while (combo.Model.IterNext (ref iter));
    

    However, generally it’s more succinct to keep your values indexed, like this:

    List<string> values = new List<string>(){"one", "two", "three"};  
    var combo = new ComboBox(values.ToArray());
    
    // Select "two"
    int row = values.IndexOf("two");
    Gtk.TreeIter iter;
    combo.Model.IterNthChild (out iter, row);
    combo.SetActiveIter (iter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
We'd like to make a few basic hook scripts that we can all share
I am really missing something with anonymous types, because I can't figure out what
I know I'm doing something wrong, but I can't figure out what I'm doing
I can't figure out how to implement this in a performing way, so I
I have three applications that talk to each other using sockets. They can all
Ok, I'm sure I am missing something obvious here but I can't figure it
I'm trying to learn the built-in features of tracing. I can't figure out how
I would like to pop up a box that warns the user of session
If you code in C and configure your compiler to insist that all functions

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.