[Gtk-sharp-list] Is there an sample on how to fill a
ComboBoxEntry with data from ADO.Net?
Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo)
vrrivaro at gmail.com
Fri Mar 10 08:26:51 EST 2006
Thak you Grant Goodyear. I appreciate that. I will try yhis out and
come back to the list.
Jesus bless you,
Victor Rivarola
2006/3/9, Grant Goodyear <grant at grantgoodyear.org>:
> Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo) wrote:
> > I have spent the last few days trying to fill a simple combo box with
> > data from a database but without success. Is there any free software
> > out there that does this under Mono and Gtk#?
>
> I've attached a file that has a set of combobox "set" properties that do
> successfully fill a combobox. I assume that there is a better way, but
> I don't know what it is.
>
> -Grant Goodyear-
>
>
> // guiview.cs -- Just what's needed to create, populate, and retrieve
> // data from the Gui.
> using System;
> using System.Collections.Generic;
> using Gtk;
> using Glade;
>
> public class GuiView {
> // widgets that get filled or read
> [Glade.Widget] private Window window1;
> [Glade.Widget] private MenuItem menuQuit;
> [Glade.Widget] private MenuItem menuAbout;
> [Glade.Widget] private CheckMenuItem menuSab;
> [Glade.Widget] private CheckMenuItem menuGenerateWW;
> [Glade.Widget] private RadioMenuItem menuUseWW;
> [Glade.Widget] private RadioMenuItem menuUseImpCards;
> [Glade.Widget] private Label labelJobNum;
> [Glade.Widget] private Label labelThickness;
> [Glade.Widget] private Label labelWater;
> [Glade.Widget] private ComboBox comboFormation;
> [Glade.Widget] private ComboBox comboTemp;
> [Glade.Widget] private ComboBox comboPressure;
> [Glade.Widget] private ComboBox comboMatrix;
> [Glade.Widget] private ComboBox comboMatrixBoron;
> [Glade.Widget] private ComboBox comboPorosity;
> [Glade.Widget] private ComboBox comboSalinity;
> [Glade.Widget] private ComboBox comboOilSat;
> [Glade.Widget] private ComboBox comboOilDensity;
> [Glade.Widget] private ComboBox comboBoreholeDiam;
> [Glade.Widget] private ComboBox comboCasingOd;
> [Glade.Widget] private ComboBox comboCement;
> [Glade.Widget] private ComboBox comboCasingWt;
> [Glade.Widget] private ComboBox comboStandoff;
> [Glade.Widget] private ComboBox comboFluid;
> [Glade.Widget] private Entry entryDensity;
> [Glade.Widget] private Entry entryNaCl;
> [Glade.Widget] private Entry entryKCl;
> [Glade.Widget] private Entry entryKCOOH;
> [Glade.Widget] private Entry entryNaCOOH;
> [Glade.Widget] private Entry entryCsCOOH;
> [Glade.Widget] private Entry entryTime;
> [Glade.Widget] private Entry entryHistories;
> [Glade.Widget] private Button buttonGenerateMCNP;
> // about box
> private Gtk.AboutDialog myabout;
> private void BuildAbout() {
> Gdk.Pixbuf mcnpicon = Gdk.Pixbuf.LoadFromResource("sxmcnp.ico");
> myabout = new AboutDialog();
> myabout.Name = "TMD-L";
> myabout.Version = "0.1";
> myabout.Copyright = "\u00a9 2006 Grant Goodyear";
> myabout.Logo = mcnpicon;
> myabout.Hide();
> myabout.DeleteEvent += delegate(object o, DeleteEventArgs a) {
> a.RetVal = true;
> myabout.Hide();
> };
> }
> // Fill or read widgets
> // .. menu items
> public bool Sab {
> get { return menuSab.Active; }
> set { menuSab.Active = value; }
> }
> public bool GenerateWW {
> get { return menuGenerateWW.Active; }
> set { menuGenerateWW.Active = value; }
> }
> public bool UseWW {
> get { return menuUseWW.Active; }
> set { menuUseWW.Active = value; }
> }
> public bool UseImpCards {
> get { return menuUseImpCards.Active; }
> set { menuUseImpCards.Active = value; }
> }
> // .. labels (write-only)
> public string LabelJobNum {
> set { labelJobNum.Text = value; }
> }
> public string LabelThickness {
> set { labelThickness.Text = value; }
> }
> public string LabelWater {
> set { labelWater.Text = value; }
> }
> // .. combo boxes
> // .. helper function to save typing
> private static void setComboText<T>(ComboBox cb, List<T> items) {
> cb.Clear();
> CellRendererText cell = new CellRendererText();
> cb.PackStart(cell, false);
> cb.AddAttribute(cell, "text", 0);
> ListStore store = new ListStore(typeof (string));
> cb.Model = store;
> foreach (T item in items) {
> store.AppendValues(item.ToString());
> }
> cb.Active = 0;
> }
> // .. Set the combobox values
> public List<string> ComboFormation {
> set { setComboText(comboFormation, value); }
> }
> // .. read or set the active item index of the combobox
> public int ComboFormationActive {
> get { return comboFormation.Active; }
> set { comboFormation.Active = value; }
> }
> public List<float> ComboTemp {
> set { setComboText(comboTemp, value); }
> }
> public int ComboTempActive {
> get { return comboTemp.Active; }
> set { comboTemp.Active = value; }
> }
> public List<float> ComboPressure {
> set { setComboText(comboPressure, value); }
> }
> public int ComboPressureActive {
> get { return comboPressure.Active; }
> set { comboPressure.Active = value; }
> }
> public List<string> ComboMatrix {
> set { setComboText(comboMatrix, value); }
> }
> public int ComboMatrixActive {
> get { return comboMatrix.Active; }
> set { comboMatrix.Active = value; }
> }
> public List<float> ComboMatrixBoron {
> set { setComboText(comboMatrixBoron, value); }
> }
> public int ComboMatrixBoronActive {
> get { return comboMatrixBoron.Active; }
> set { comboMatrixBoron.Active = value; }
> }
> public List<float> ComboPorosity {
> set { setComboText(comboPorosity, value); }
> }
> public int ComboPorosityActive {
> get { return comboPorosity.Active; }
> set { comboPorosity.Active = value; }
> }
> public List<float> ComboSalinity {
> set { setComboText(comboSalinity, value); }
> }
> public int ComboSalinityActive {
> get { return comboSalinity.Active; }
> set { comboSalinity.Active = value; }
> }
> public List<float> ComboOilSat {
> set { setComboText(comboOilSat, value); }
> }
> public int ComboOilSatActive {
> get { return comboOilSat.Active; }
> set { comboOilSat.Active = value; }
> }
> public List<float> ComboOilDensity {
> set { setComboText(comboOilDensity, value); }
> }
> public int ComboOilDensityActive {
> get { return comboOilDensity.Active; }
> set { comboOilDensity.Active = value; }
> }
> public List<float> ComboBoreholeDiam {
> set { setComboText(comboBoreholeDiam, value); }
> }
> public int ComboBoreholeDiamActive {
> get { return comboBoreholeDiam.Active; }
> set { comboBoreholeDiam.Active = value; }
> }
> public List<float> ComboCasingOd {
> set { setComboText(comboCasingOd, value); }
> }
> public int ComboCasingOdActive {
> get { return comboCasingOd.Active; }
> set { comboCasingOd.Active = value; }
> }
> public List<string> ComboCement {
> set { setComboText(comboCement, value); }
> }
> public int ComboCementActive {
> get { return comboCement.Active; }
> set { comboCement.Active = value; }
> }
> public List<float> ComboCasingWt {
> set { setComboText(comboCasingWt, value); }
> }
> public int ComboCasingWtActive {
> get { return comboCasingWt.Active; }
> set { comboCasingWt.Active = value; }
> }
> public List<float> ComboStandoff {
> set { setComboText(comboStandoff, value); }
> }
> public int ComboStandoffActive {
> get { return comboStandoff.Active; }
> set { comboStandoff.Active = value; }
> }
> public List<string> ComboFluid {
> set { setComboText(comboFluid, value); }
> }
> public int ComboFluidActive {
> get { return comboFluid.Active; }
> set { comboFluid.Active = value; }
> }
> // .. entries
> public string EntryDensity {
> get { return entryDensity.Text; }
> set { entryDensity.Text = value; }
> }
> public string EntryNaCl {
> get { return entryNaCl.Text; }
> set { entryNaCl.Text = value; }
> }
> public string EntryKCl {
> get { return entryKCl.Text; }
> set { entryKCl.Text = value; }
> }
> public string EntryKCOOH {
> get { return entryKCOOH.Text; }
> set { entryKCOOH.Text = value; }
> }
> public string EntryNaCOOH {
> get { return entryNaCOOH.Text; }
> set { entryNaCOOH.Text = value; }
> }
> public string EntryCsCOOH {
> get { return entryCsCOOH.Text; }
> set { entryCsCOOH.Text = value; }
> }
> public string EntryTime {
> get { return entryTime.Text; }
> set { entryTime.Text = value; }
> }
> public string EntryHistories {
> get { return entryHistories.Text; }
> set { entryHistories.Text = value; }
> }
> // .. sensitivities (for widgets we want to "grey out")
> public bool ComboTempSensitive {
> set { comboTemp.Sensitive = value; }
> }
> public bool ComboPressureSensitive {
> set { comboPressure.Sensitive = value; }
> }
> public bool ComboMatrixSensitive {
> set { comboMatrix.Sensitive = value; }
> }
> public bool ComboMatrixBoronSensitive {
> set { comboMatrixBoron.Sensitive = value; }
> }
> public bool ComboPorositySensitive {
> set { comboPorosity.Sensitive = value; }
> }
> public bool ComboSalinitySensitive {
> set { comboSalinity.Sensitive = value; }
> }
> public bool ComboOilSatSensitive {
> set { comboOilSat.Sensitive = value; }
> }
> public bool ComboOilDensitySensitive {
> set { comboOilDensity.Sensitive = value; }
> }
> public bool ComboCasingOdSensitive {
> set { comboCasingOd.Sensitive = value; }
> }
> public bool ComboCementSensitive {
> set { comboCement.Sensitive = value; }
> }
> public bool ComboCasingWtSensitive {
> set { comboCasingWt.Sensitive = value; }
> }
> public bool EntryDensitySensitive {
> set { entryDensity.Sensitive = value; }
> }
> public bool EntryNaClSensitive {
> set { entryNaCl.Sensitive = value; }
> }
> public bool EntryKClSensitive {
> set { entryKCl.Sensitive = value; }
> }
> public bool EntryKCOOHSensitive {
> set { entryKCOOH.Sensitive = value; }
> }
> public bool EntryNaCOOHSensitive {
> set { entryNaCOOH.Sensitive = value; }
> }
> public bool EntryCsCOOHSensitive {
> set { entryCsCOOH.Sensitive = value; }
> }
> public GuiView() {
> Application.Init();
> Glade.XML gxml = new Glade.XML(null, "tmdl.glade", "window1", null);
> gxml.Autoconnect(this);
> BuildAbout();
> // events
> window1.DeleteEvent += delegate { Application.Quit(); };
> menuQuit.Activated += delegate { Application.Quit(); };
> menuAbout.Activated += delegate { myabout.Show(); };
> myabout.DeleteEvent += delegate(object o, DeleteEventArgs args) {
> args.RetVal = true;
> myabout.Hide();
> };
> buttonGenerateMCNP.Clicked += delegate {};
> comboFormation.Changed += ComboChanged;
> comboFluid.Changed += ComboChanged;
> }
> public void Run() {
> Application.Run();
> }
> public event System.EventHandler ComboUpdated;
> public event System.EventHandler FieldsUpdated;
> public event System.EventHandler Execute;
> private void ComboChanged(object o, EventArgs args) {
> if (ComboUpdated != null)
> ComboUpdated(o, args);
> }
> }
>
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
>
--
FANÁTICO
"Por cuanto eres tibio, y no frío ni caliente, te vomitaré de mi boca."
Apocalipsis 3:16
LOCO
"Porque la Palabra de la Cruz es locura para los que se pierden; pero a
los que se salvan, esto es, a nosotros, es poder de Dios."
1 Corintios 1:18
More information about the Gtk-sharp-list
mailing list