I'll give it a go.. I don't think I've done any sorting so should be ok and maybe a quick lambda expression may get the row index..
I just don't understand why gtk# makes handling list objects and data binding... On 19 Sep 2013 20:56, "Moonfire, D." <[email protected]> wrote: > Basically, you want to set comboBox.Active to the index of your item. If > you happen to know it ahead of time, then go for it. If you can't, then > just loop through the list store to fine the item. I got tired of doing a > lot of these and started putting them into a subclasses ComboBox over in my > MfGames.GtkExt library, but I haven't gotten serious about merging all the > individual branches to make it that useful. > > > https://github.com/dmoonfire/mfgames-gtkext-cil/blob/master/src/MfGames.GtkExt/EnumComboBox.cs > > Below is an example of how I did it. This predates my understanding of > LINQ, so it's a bit clumsy. Effectively, I wrote a combo box that takes an > enumeration and displays the values (and returns/sets it via said enum). > > ComboBox comboBox; > > // Go through the elements and find the string value > string str = value.ToString(); > > var store = (ListStore) comboBox.Model; > int index = 0; > > foreach (object[] row in store) > { > // Check for match > if (str == row[0].ToString()) > { > comboBox.Active = index; > break; > } > > // Increment the index so we can reference it for the active. > index++; > } > > > > > On Thu, Sep 19, 2013 at 10:56 AM, jaymarvels < > [email protected]> wrote: > >> I don't want to get. I want to set. >> >> I'll explain again >> >> I have a liststore...2 columns >> >> America 10 >> Belgium 16 >> England 139 >> Denmark 166 >> >> This is then bound to the combobox. >> >> >> cboNations.Clear (); >> Gtk.CellRendererText text = new CellRendererText >> (); >> cboNations.Model = datalist; >> cboNations.PackStart (text, false); >> cboNations.AddAttribute (text, "text", 0); >> >> >> I want to set the initial selectedvalue = 139 or something else of my >> choosing. >> >> In winforms this would be done by setting my combobox datasource to a >> object >> class.. >> >> And then doing a combobox selectedvalue = 139; >> >> >> >> -- >> View this message in context: >> http://mono.1490590.n4.nabble.com/Mono-GTK-Set-Combobox-Selected-by-Value-tp4660923p4660926.html >> Sent from the Mono - Gtk# mailing list archive at Nabble.com. >> _______________________________________________ >> Gtk-sharp-list maillist - [email protected] >> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list >> > >
_______________________________________________ Gtk-sharp-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
