[Gtk-sharp-list] ComboBox and keyboard

Madian madian001 at gmail.com
Thu Mar 5 11:48:54 EST 2009

I know it's to late but i hope this could help to oters users,
If you are tying to implement something like the datasource or datamember of
windows forms controlls remember in GTK there is something called MVC(modell
view controller)
see: http://en.wikipedia.org/wiki/Model-view-controller

ok, so you can fill or get back data from a database whit this sub

We will supose that have a table whit tow fields(Id, Name)
//I don't now why but always the first column it must to be string,
//(if you want to enable the entrycompletion)
//and the type of the others columns it does not matter.

public static void FillCombo (ComboBoxEntry cbo,string qry)
	string error = "";
	MySqlCommand cmd = new MySqlCommand();
	MySqlDataReader dr;
	MySqlConnection cn = new MySqlConnection(strConnectionString);
		cmd.CommandText = qry;
		cmd.Connection = cn;
		dr = cmd.ExecuteReader();
		if (dr.HasRows)
			ListStore store = new ListStore (typeof (string),typeof(int));
			while (dr.Read())
				store.AppendValues (dr.GetString(1),dr.GetInt32(0));
			cbo.Model = store;
			cbo.Entry.Completion = new EntryCompletion();
			cbo.Entry.Completion.Model = store;
			cbo.Entry.Completion.TextColumn = 0;
	}catch(MySqlException ex){
		error = ex.Message+" "+ex.Number;
	}catch(Exception e){
		error = e.Message;
		if (error.Length>0)
Any doubt mail me please

View this message in context: http://www.nabble.com/ComboBox-and-keyboard-tp161205p22355585.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

More information about the Gtk-sharp-list mailing list