[Fwd: [Gtk-sharp-list] ComboBox AppendText and Active]

Daniel Morgan danielmorgan at verizon.net
Sat Jun 25 20:34:44 EDT 2005


Here is a customization we could use:

        public int SetActiveText (string text)
        {
            // returns index that was set; otherwise -1 if it could not

            int comboIndex = 0;
            string tvalue;
            TreeIter iter;

            combo.Model.IterChildren (out iter);
            tvalue  = combo.Model.GetValue (iter, 0).ToString();
            if (tvalue.Equals (text)) {
                combo.Active = comboIndex;
                return comboIndex;
            }
            else {
                bool found = combo.Model.IterNext (ref iter);
                while (found == true) {
                    comboIndex ++;
                    tvalue = combo.Model.GetValue (iter, 0).ToString();
                    if (tvalue.Equals (text)) {
                        combo.Active = comboIndex;
                        return comboIndex;
                    }
                    else
                        found = combo.Model.IterNext (ref iter);
                }
            }

            return -1; // not found
        }


-------------- next part --------------
An embedded message was scrubbed...
From: Daniel Morgan <danielmorgan at verizon.net>
Subject: [Gtk-sharp-list] ComboBox AppendText and Active
Date: Sat, 25 Jun 2005 19:59:59 -0400
Size: 3797
Url: http://galactus.ximian.com/pipermail/gtk-sharp-list/attachments/20050625/cd4deae0/Gtk-sharp-listComboBoxAppendTextandActive.mht


More information about the Gtk-sharp-list mailing list