当前位置: 首页>>代码示例>>C#>>正文


C# Gtk.ComboBox类代码示例

本文整理汇总了C#中Gtk.ComboBox的典型用法代码示例。如果您正苦于以下问题:C# ComboBox类的具体用法?C# ComboBox怎么用?C# ComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComboBox类属于Gtk命名空间,在下文中一共展示了ComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetActiveText

		public static bool SetActiveText (ComboBox cbox, string text) 
		{
			// returns true if found, false if not found

			string tvalue;
			TreeIter iter;
			ListStore store = (ListStore) cbox.Model;

			store.IterChildren (out iter);
			tvalue  = store.GetValue (iter, 0).ToString();
			if (tvalue.Equals (text)) {
				cbox.SetActiveIter (iter);
				return true;
			}
			else {
				bool found = store.IterNext (ref iter);
				while (found == true) {
					tvalue = store.GetValue (iter, 0).ToString();
					if (tvalue.Equals (text)) {
						cbox.SetActiveIter (iter);
						return true;
					}
					else
						found = store.IterNext (ref iter);
				}
			}

			return false; // not found
		}
开发者ID:emtees,项目名称:old-code,代码行数:29,代码来源:ComboHelper.cs

示例2: ApplicationWidget

        public ApplicationWidget(Project project,Gtk.Window parent)
        {
            parentWindow =parent;
            this.Build();
            this.project = project;

            cbType = new ComboBox();

            ListStore projectModel = new ListStore(typeof(string), typeof(string));
            CellRendererText textRenderer = new CellRendererText();
            cbType.PackStart(textRenderer, true);
            cbType.AddAttribute(textRenderer, "text", 0);

            cbType.Model= projectModel;

            TreeIter ti = new TreeIter();
            foreach(SettingValue ds in MainClass.Settings.ApplicationType){// MainClass.Settings.InstallLocations){
                if(ds.Value == this.project.ApplicationType){
                    ti = projectModel.AppendValues(ds.Display,ds.Value);
                    cbType.SetActiveIter(ti);
                } else  projectModel.AppendValues(ds.Display,ds.Value);
            }
            if(cbType.Active <0)
                cbType.Active =0;

            tblGlobal.Attach(cbType, 1, 2, 0,1, AttachOptions.Fill|AttachOptions.Expand, AttachOptions.Fill|AttachOptions.Expand, 0, 0);

            afc = new ApplicationFileControl(project.AppFile,ApplicationFileControl.Mode.EditNoSaveButton,parentWindow);
            vbox2.PackEnd(afc, true, true, 0);
        }
开发者ID:moscrif,项目名称:ide,代码行数:30,代码来源:ApplicationPanel.cs

示例3: EnumEditor

		public EnumEditor(object @object, PropertyInfo info) : base(@object, info) {
			Type type = info.PropertyType;
			
			foreach (FieldInfo fi in type.GetFields()) {
				if (!fi.IsStatic || fi.FieldType != type)
					continue;
				
				string name = fi.Name;
				
				DisplayNameAttribute dispname = Util.GetAttribute<DisplayNameAttribute>(fi, false);
				if (dispname != null)
					name = dispname.DisplayName;
				
				object value = fi.GetValue(null);
				
				this.mStore.AppendValues(new EnumValue(value, name));
			}
			
			this.mCombo = new ComboBox(this.mStore);
			CellRendererText renderer = new CellRendererText();
			this.mCombo.PackStart(renderer, true);
			this.mCombo.SetCellDataFunc(renderer, ComboFunc);
			
			this.mCombo.Show();
			this.Add(this.mCombo);
			
			this.mCombo.Changed += this.OnComboChanged;
			
			this.Revert();
		}
开发者ID:Bamistro,项目名称:openvisualizationplatform,代码行数:30,代码来源:EnumEditor.cs

示例4: ErrorMatrixPanel

        public ErrorMatrixPanel(uint rows, uint cols)
            : base(4, 2, false)
        {
            divisorSpinButton = new SpinButton(1, 10000, 1);
            sourceOffsetXSpinButton = new SpinButton(1, cols, 1);
            customDivisorCheckButton = new CheckButton("Use a custom divisor?");
            customDivisorCheckButton.Toggled += delegate
            {
                divisorSpinButton.Sensitive = customDivisorCheckButton.Active;
            };

            matrixPanel = new MatrixPanel(rows, cols);
            matrixPanel.MatrixResized += delegate
            {
                sourceOffsetXSpinButton.Adjustment.Upper =
                    matrixPanel.Columns;
            };

            presets = new List<ErrorMatrix>(ErrorMatrix.Samples.listMatrices());
            var presetsNames = from preset in presets select preset.Name;
            presetComboBox = new ComboBox(presetsNames.ToArray());
            presetComboBox.Changed += delegate
            {
                int active = presetComboBox.Active;
                if (active >= 0) {
                    Matrix = presets[active];
                }
            };

            ColumnSpacing = 2;
            RowSpacing = 2;
            BorderWidth = 2;

            Attach(new Label("Preset:") { Xalign = 0.0f }, 0, 1, 0, 1,
                AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Shrink, 0, 0);
            Attach(presetComboBox, 1, 2, 0, 1,
                AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Shrink, 0, 0);

            Attach(matrixPanel, 0, 2, 1, 2,
                AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Fill | AttachOptions.Expand, 0, 0);

            Attach(new Label("Source offset X:") { Xalign = 0.0f },
                0, 1, 2, 3, AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Shrink, 0, 0);
            Attach(sourceOffsetXSpinButton, 1, 2, 2, 3,
                AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

            Attach(customDivisorCheckButton, 0, 2, 3, 4,
                AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Shrink, 0, 0);

            Attach(new Label("Divisor:") { Xalign = 0.0f }, 0, 1, 4, 5,
                AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Shrink, 0, 0);
            Attach(divisorSpinButton, 1, 2, 4, 5,
                AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
        }
开发者ID:bzamecnik,项目名称:HalftoneLab,代码行数:60,代码来源:ErrorMatrixPanel.cs

示例5: ComboPlaceNoFill

        public static void ComboPlaceNoFill(ComboBox combo, int Type_id)
        {
            //Заполняем комбобокс Номерами мест
            try {
                logger.Info ("Запрос номеров мест...");
                int count = 0;
                string sql = "SELECT place_no FROM places " +
                             "WHERE type_id = @type_id";
                MySqlCommand cmd = new MySqlCommand (sql, QSMain.connectionDB);
                cmd.Parameters.AddWithValue ("@type_id", Type_id);
                MySqlDataReader rdr = cmd.ExecuteReader ();

                while (rdr.Read ()) {
                    combo.AppendText (rdr ["place_no"].ToString ());
                    count++;
                }
                rdr.Close ();
                if (count == 1)
                    combo.Active = 0;

                logger.Info ("Ok");
            } catch (Exception ex) {
                logger.Error (ex, "Ошибка получения номеров мест!");
            }
        }
开发者ID:QualitySolution,项目名称:LeaseAgreement,代码行数:25,代码来源:Main.cs

示例6: MainWindow_Widget

        public MainWindow_Widget()
            : base("You know I'm no good")
        {
            SetDefaultSize(800, 600);

            BorderWidth = 8;
            SetPosition(WindowPosition.Center);

            // Title
            Title = "Widget Test";

            // Label
            DeleteEvent += delegate
            {
                    Application.Quit();
            };

            Fixed fix = new Fixed();

            ComboBox combo = new ComboBox(distros);
            combo.Changed += OnChanged;

            lyrics = new Label(text);

            fix.Put(combo, 50, 30);
            fix.Put(lyrics, 50, 150);

            Add(fix);

            ShowAll();
        }
开发者ID:oraora81,项目名称:NOCmono,代码行数:31,代码来源:MainWindow_Widget.cs

示例7: GetId

 public static object GetId(ComboBox comboBox)
 {
     TreeIter treeIter;
     comboBox.GetActiveIter (out treeIter);
     IList row = (IList)comboBox.Model.GetValue (treeIter, 0); //ILIST 0 por que es el unico elemento aunque dentro vallan las columnas
     return row [0];
 }
开发者ID:skounah,项目名称:2DAM-AD,代码行数:7,代码来源:ComboBoxHelper.cs

示例8: GroupsChanged

		void GroupsChanged ()
		{
			if (combo != null) {
				combo.Changed -= combo_Changed;
				Remove (combo);
			}

			combo = Gtk.ComboBox.NewText ();
			combo.Changed += combo_Changed;
#if GTK_SHARP_2_6
			combo.RowSeparatorFunc = RowSeparatorFunc;
#endif
			combo.Show ();
			PackStart (combo, true, true, 0);

			values = new ArrayList ();
			int i = 0;
			foreach (string name in manager.GroupNames) {
				values.Add (name);
				combo.AppendText (name);
				if (name == group)
					combo.Active = i;
				i++;
			}

#if GTK_SHARP_2_6
			combo.AppendText ("");
#endif

			combo.AppendText (Catalog.GetString ("Rename Group..."));
			combo.AppendText (Catalog.GetString ("New Group..."));
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:32,代码来源:GroupPicker.cs

示例9: ComboBoxHelper

        public ComboBoxHelper(IDbConnection dbConnection,ComboBox comboBox,string nombre, string id,int elementoInicial,string tabla)
        {
            this.comboBox=comboBox;

            IDbCommand dbCommand= dbConnection.CreateCommand();
            dbCommand.CommandText = string.Format(selectFormat,id,nombre,tabla);

            IDataReader dbDataReader= dbCommand.ExecuteReader();

            //			CellRendererText cell1=new CellRendererText();
            //			comboBox.PackStart(cell1,false);
            //			comboBox.AddAttribute(cell1,"text",0);

            CellRendererText cell2=new CellRendererText();
            comboBox.PackStart(cell2,false);
            comboBox.AddAttribute(cell2,"text",1);//añadimos columnas
            liststore=new ListStore(typeof(int),typeof(string));

            TreeIter initialIter= liststore.AppendValues(0,"<sin asignar>");//si el elemento inicial no existe se selecciona esta opcion
            while(dbDataReader.Read()){
                int id2=(int)dbDataReader[id];
                string nombre2=dbDataReader[nombre].ToString();
                TreeIter iter=liststore.AppendValues(id2,nombre2);
                if(elementoInicial==id2)
                    initialIter=iter;
            }
            dbDataReader.Close();
            comboBox.Model=liststore;
            comboBox.SetActiveIter(initialIter);
        }
开发者ID:nerea123,项目名称:ad,代码行数:30,代码来源:ComboBoxHelper.cs

示例10: InitializeExtraWidget

        protected void InitializeExtraWidget()
        {
            PlaylistFormatDescription [] formats = PlaylistFileUtil.ExportFormats;
            int default_export_index = PlaylistFileUtil.GetFormatIndex(formats, playlist);

            // Build custom widget used to select the export format.
            store = new ListStore(typeof(string), typeof(PlaylistFormatDescription));
            foreach (PlaylistFormatDescription format in formats) {
                store.AppendValues(format.FormatName, format);
            }

            HBox hBox = new HBox(false, 2);

            combobox = new ComboBox(store);
            CellRendererText crt = new CellRendererText();
            combobox.PackStart(crt, true);
            combobox.SetAttributes(crt, "text", 0);
            combobox.Active = default_export_index;
            combobox.Changed += OnComboBoxChange;

            hBox.PackStart(new Label(Catalog.GetString("Select Format: ")), false, false, 0);
            hBox.PackStart(combobox, true, true, 0);

            combobox.ShowAll();
            hBox.ShowAll();
            ExtraWidget = hBox;
        }
开发者ID:haugjan,项目名称:banshee-hacks,代码行数:27,代码来源:PlaylistExportDialog.cs

示例11: BuildInterface

        private void BuildInterface ()
        {
            field_chooser = ComboBox.NewText ();
            field_chooser.Changed += HandleFieldChanged;

            op_chooser = ComboBox.NewText ();
            op_chooser.RowSeparatorFunc = IsRowSeparator;
            op_chooser.Changed += HandleOperatorChanged;

            value_box = new HBox ();

            remove_button = new Button (new Image ("gtk-remove", IconSize.Button));
            remove_button.Relief = ReliefStyle.None;
            remove_button.Clicked += OnButtonRemoveClicked;

            add_button = new Button (new Image ("gtk-add", IconSize.Button));
            add_button.Relief = ReliefStyle.None;
            add_button.Clicked += OnButtonAddClicked;

            button_box = new HBox ();
            button_box.PackStart (remove_button, false, false, 0);
            button_box.PackStart (add_button, false, false, 0);

            foreach (QueryField field in sorted_fields) {
                field_chooser.AppendText (field.Label);
            }

            Show ();
            field_chooser.Active = 0;
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:30,代码来源:QueryTermBox.cs

示例12: ComboAccrualYearsFill

        public static void ComboAccrualYearsFill(ComboBox combo, params string[] firstItems)
        {
            try {
                logger.Info ("Запрос лет для начислений...");
                TreeIter iter;
                string sql = "SELECT DISTINCT year FROM accrual ORDER BY year DESC";
                MySqlCommand cmd = new MySqlCommand (sql, QSMain.connectionDB);
                MySqlDataReader rdr = cmd.ExecuteReader ();

                ((ListStore)combo.Model).Clear ();

                foreach(var item in firstItems)
                {
                    combo.AppendText (item);
                }

                combo.AppendText (Convert.ToString (DateTime.Now.AddYears (1).Year));
                combo.AppendText (Convert.ToString (DateTime.Now.Year));
                while (rdr.Read ()) {
                    if (rdr.GetUInt32 ("year") == DateTime.Now.Year || rdr.GetUInt32 ("year") == DateTime.Now.AddYears (1).Year)
                        continue;
                    combo.AppendText (rdr ["year"].ToString ());
                }
                rdr.Close ();
                ((ListStore)combo.Model).SetSortColumnId (0, SortType.Descending);
                ListStoreWorks.SearchListStore ((ListStore)combo.Model, Convert.ToString (DateTime.Now.Year), out iter);
                combo.SetActiveIter (iter);
                logger.Info ("Ok");
            } catch (Exception ex) {
                logger.Warn (ex, "Ошибка получения списка лет!");
            }
        }
开发者ID:QualitySolution,项目名称:Bazar,代码行数:32,代码来源:Main.cs

示例13: Initialize

		public void Initialize (EditSession session)
		{
			this.session = session;
			
			//if standard values are supported by the converter, then 
			//we list them in a combo
			if (session.Property.Converter.GetStandardValuesSupported (session))
			{
				store = new ListStore (typeof(string), typeof(object));

				//if converter doesn't allow nonstandard values, or can't convert from strings, don't have an entry
				if (session.Property.Converter.GetStandardValuesExclusive (session) || !session.Property.Converter.CanConvertFrom (session, typeof(string))) {
					combo = new ComboBox (store);
					var crt = new CellRendererText ();
					combo.PackStart (crt, true);
					combo.AddAttribute (crt, "text", 0);
				} else {
					combo = new ComboBoxEntry (store, 0);
					entry = ((ComboBoxEntry)combo).Entry;
					entry.HeightRequest = combo.SizeRequest ().Height;
				}

				PackStart (combo, true, true, 0);
				combo.Changed += TextChanged;
				
				//fill the list
				foreach (object stdValue in session.Property.Converter.GetStandardValues (session)) {
					store.AppendValues (session.Property.Converter.ConvertToString (session, stdValue), ObjectBox.Box (stdValue));
				}
				
				//a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
				object[] atts = session.Property.Converter.GetType ()
					.GetCustomAttributes (typeof (StandardValuesSeparatorAttribute), true);
				if (atts.Length > 0) {
					string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
					combo.RowSeparatorFunc = (model, iter) => separator == ((string)model.GetValue (iter, 0));
				}
			}
			// no standard values, so just use an entry
			else {
				entry = new Entry ();
				PackStart (entry, true, true, 0);
			}

			//if we have an entry, fix it up a little
			if (entry != null) {
				entry.HasFrame = false;
				entry.Changed += TextChanged;
				entry.FocusOutEvent += FirePendingChangeEvent;
			}

			if (entry != null && ShouldShowDialogButton ()) {
				var button = new Button ("...");
				PackStart (button, false, false, 0);
				button.Clicked += ButtonClicked;
			}
			
			Spacing = 3;
			ShowAll ();
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:60,代码来源:TextEditor.cs

示例14: creaVentanaArticulo

        public void creaVentanaArticulo()
        {
            titulo="Añadir articulo";
            ventana(titulo);
            Label cat=new Label("Introduce el nombre del nuevo articulo: ");
            text= new Entry();
            ComboBox cb=new ComboBox();
            Label cat2=new Label("Selecciona la categoria: ");
            combot= new ComboBoxHelper(App.Instance.DbConnection,cb,"nombre","id",0,"categoria");
            tabla.Attach(cat,0,1,0,1);
            tabla.Attach(text,1,2,0,1);
            tabla.Attach(cat2,0,1,1,2);
            tabla.Attach(cb,1,2,1,2);
            Label pre=new Label("Introduce el precio del nuevo articulo: ");
            precio=new Entry();
            tabla.Attach(pre,0,1,2,3);
            tabla.Attach(precio,1,2,2,3);
            Button button=new Button("Añadir");
                    button.Clicked +=delegate{
                    añadirArticulo(App.Instance.DbConnection);
                    if(!enBlanco){
                        window.Destroy();
                        refresh();
                }
            };

            tabla.Attach(button,1,2,3,4);
            window.Add(vbox);
            window.ShowAll();
        }
开发者ID:nerea123,项目名称:ad,代码行数:30,代码来源:ArticuloListView.cs

示例15: ToolBarComboBox

        public ToolBarComboBox(int width, int activeIndex, bool allowEntry, params string[] contents)
        {
            if (allowEntry)
                ComboBox = new ComboBoxEntry (contents);
            else {
                Model = new ListStore (typeof(string), typeof (object));
                if (contents != null) {
                    foreach (string entry in contents) {
                        Model.AppendValues (entry, null);
                    }
                }
                ComboBox = new ComboBox ();
                ComboBox.Model = Model;
                CellRendererText = new CellRendererText();
                ComboBox.PackStart(CellRendererText, false);
                ComboBox.AddAttribute(CellRendererText,"text",0);
            }

            ComboBox.AddEvents ((int)Gdk.EventMask.ButtonPressMask);
            ComboBox.WidthRequest = width;

            if (activeIndex >= 0)
                ComboBox.Active = activeIndex;

            ComboBox.Show ();

            Add (ComboBox);
            Show ();
        }
开发者ID:RodH257,项目名称:Pinta,代码行数:29,代码来源:ToolBarComboBox.cs


注:本文中的Gtk.ComboBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。