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


C# ComboBox.SetActiveIter方法代码示例

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


在下文中一共展示了ComboBox.SetActiveIter方法的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: ComboBoxHelper

        public ComboBoxHelper(ComboBox comboBox, object id, string selectSql)
        {
            CellRendererText cellRendererText = new CellRendererText ();
            comboBox.PackStart (cellRendererText, false);
            comboBox.SetCellDataFunc (cellRendererText, new CellLayoutDataFunc (delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                cellRendererText.Text = ((object[])tree_model.GetValue(iter, 0))[1].ToString();
            }));

            ListStore listStore = new ListStore (typeof(object));
            object[] initial = new object[] { null, "<sin asignar>" };
            TreeIter initialTreeIter = listStore.AppendValues ((object)initial);

            IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand ();
            dbCommand.CommandText = selectSql;
            IDataReader dataReader = dbCommand.ExecuteReader ();
            while (dataReader.Read()) {
                object currentId = dataReader [0];
                object currentName = dataReader [1];
                object[] values = new object[] { currentId, currentName };
                TreeIter treeIter = listStore.AppendValues ((object)values);
                if (currentId.Equals (id))
                    initialTreeIter = treeIter;
            }
            dataReader.Close ();
            comboBox.Model = listStore;
            comboBox.SetActiveIter (initialTreeIter);
        }
开发者ID:crivaly,项目名称:AD,代码行数:27,代码来源:ComboBoxHelper.cs

示例3: 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

示例4: 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

示例5: ComboBoxHelper

        public ComboBoxHelper(
			ComboBox comboBox, 
			IDbConnection dbConnection, 
			string keyFieldName, 
			string valueFieldName, 
			string tableName, 
			int id)
        {
            this.comboBox = comboBox;

            CellRendererText cellRendererText = new CellRendererText();
            comboBox.PackStart (cellRendererText, true);
            comboBox.AddAttribute (cellRendererText, "text", 1);

            listStore = new ListStore(typeof(int), typeof(string));
            TreeIter initialTreeIter = listStore.AppendValues(0, "<sin asignar>");
            IDbCommand dbCommand = dbConnection.CreateCommand ();
            dbCommand.CommandText = string.Format(selectFormat, keyFieldName, valueFieldName, tableName);
            IDataReader dataReader = dbCommand.ExecuteReader ();
            while (dataReader.Read ()) {
                int key = (int)dataReader[keyFieldName];
                string value = (string)dataReader[valueFieldName];
                TreeIter treeIter = listStore.AppendValues (key, value);
                if (key == id)
                    initialTreeIter = treeIter;
            }
            dataReader.Close ();

            comboBox.Model = listStore;
            comboBox.SetActiveIter (initialTreeIter);
        }
开发者ID:ruben206,项目名称:ad,代码行数:31,代码来源:ComboBoxHelper.cs

示例6: 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

示例7: Fill

        public static void Fill(ComboBox comboBox, QueryResult queryResult)
        {
            CellRendererText cellRenderText = new CellRendererText ();

            comboBox.PackStart (cellRenderText, false);
            comboBox.SetCellDataFunc(cellRenderText,
                delegate(CellLayout Cell_layout, CellRenderer CellView, TreeModel tree_model, TreeIter iter) {
                IList row = (IList)tree_model.GetValue(iter, 0);
                cellRenderText.Text = row[1].ToString();

                //Vamos a ver el uso de los parámetros para acceder a SQL

            });

            ListStore listStore = new ListStore (typeof(IList));

            //TODO localización de "Sin Asignar".
            IList first = new object[] { null, "<sin asignar>" };
            TreeIter treeIterFirst = listStore.AppendValues (first);
            //TreeIter treeIterFirst = ListStore.AppendValues(first);
            foreach (IList row in queryResult.Rows)
                listStore.AppendValues (row);
            comboBox.Model = listStore;
            //Por defecto vale -1 (para el indice de categoría)
            comboBox.Active = 0;
            comboBox.SetActiveIter(treeIterFirst);
        }
开发者ID:miguelangelrosales,项目名称:AD,代码行数:27,代码来源:ComboBoxHerlper.cs

示例8: SetComboBoxValue

        public static void SetComboBoxValue(ComboBox comboBox, string text)
        {
            comboBox.Model.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
            {
                if (string.Equals(text, (string)model.GetValue(iter, 0)))
                {
                    comboBox.SetActiveIter(iter);
                    return (true);
                }

                return (false);
            });
        }
开发者ID:synesthesiam,项目名称:nexus,代码行数:13,代码来源:GTKUtility.cs

示例9: PopulateComboBox

        private void PopulateComboBox(ComboBox combobox, string active,
            IEnumerable<string> enumerable)
        {
            ListStore model = new ListStore (typeof (string));
            combobox.Model = model;

            foreach (string s in enumerable) {
                TreeIter iter = model.AppendValues (s);
                if (s == active)
                    combobox.SetActiveIter (iter);
            }

            CellRendererText cr = new CellRendererText ();
            combobox.PackStart (cr, false);
            combobox.AddAttribute (cr, "text", 0);
        }
开发者ID:manicolosi,项目名称:questar,代码行数:16,代码来源:PreferenceDialog.cs

示例10: ComboBoxHelper

        public ComboBoxHelper(ComboBox comboBox, IDbConnection dbConnection, string keyFieldName,
		                       string valueFieldName,string tableName,int initialId)
        {
            this.comboBox = comboBox;
            //this.initalId = initialId;

            CellRendererText cellRenderText1 = new CellRendererText();
            comboBox.PackStart(cellRenderText1,false);
            comboBox.AddAttribute(cellRenderText1,"text",0);//el ultimo parametro el 0 sirve para elegir la columna a visualizar

            CellRendererText cellRenderText = new CellRendererText();
            comboBox.PackStart(cellRenderText,false);
            comboBox.AddAttribute(cellRenderText,"text",1);//el ultimo parametro el 1 sirve para elegir la columna a visualizar

            listStore = new ListStore(typeof(int),typeof(string));

            TreeIter initialTreeIter;/* = listStore.AppendValues(0, "Sin asignar");*/
            IDbCommand dbCommand = dbConnection.CreateCommand();
            dbCommand.CommandText = string.Format(selectFormat, keyFieldName,valueFieldName,tableName);
            IDataReader dataReader = dbCommand.ExecuteReader();

            //Recorre el dataReader para insertar los valores en el comboBox
            while(dataReader.Read())
            {
                int id =(int) dataReader["id"];
                string nombre = (string)dataReader["nombre"];
                treeIter = listStore.AppendValues(id,nombre);
                if (id == initialId)
                    initialTreeIter = treeIter;
            }

            dataReader.Close();
            comboBox.Model = listStore;
            comboBox.SetActiveIter(initialTreeIter);

            comboBox.Changed += delegate {
                TreeIter treeIter;
                comboBox.GetActiveIter(out treeIter);
                int id = (int) listStore.GetValue(treeIter,0);

                Console.WriteLine("ID = "+ id);
            };
        }
开发者ID:CristianAguerreClavel,项目名称:ad,代码行数:43,代码来源:ComboBoxHelper.cs

示例11: Fill

 public static void Fill(ComboBox comboBox, QueryResult queryResult, object id)
 {
     CellRendererText cellRendererText = new CellRendererText ();
     comboBox.PackStart (cellRendererText, false);
     comboBox.SetCellDataFunc (cellRendererText,
                               delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
         IList row = (IList)tree_model.GetValue(iter, 0);
         cellRendererText.Text = row[1].ToString();
     });
     ListStore listStore = new ListStore (typeof(IList));
     //TODO localización de "sin asignar"
     IList first = new object[]{null, "<sin asignar>"};
     TreeIter treeIterFirst = listStore.AppendValues (first);
     foreach (IList row in queryResult.Rows)
         listStore.AppendValues (row);
     comboBox.Model = listStore;
     //comboBox.Active = 0;
     comboBox.SetActiveIter (treeIterFirst);
 }
开发者ID:oscargarciagarcia,项目名称:ad,代码行数:19,代码来源:ComboBoxHelper.cs

示例12: Fill

 public static void Fill(ComboBox comboBox,QueryResult queryResult, object id)
 {
     CellRendererText cellRendererText = new CellRendererText ();
     comboBox.PackStart (cellRendererText, false);
     comboBox.SetCellDataFunc (cellRendererText, delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {	//ESTA Y LA ANTERIOR CREAN LA CAJA PARA DIBUJAR
         IList row =(IList)tree_model.GetValue(iter,0);
         cellRendererText.Text = /*row[0] +" - "+*/ row[1].ToString();       // Id - Categoria
     });
     ListStore listStore = new ListStore (typeof(IList));
     IList first = new object[] {null, "<sin asignar>"};
     TreeIter treeIterAsignado =listStore.AppendValues (first); // lo guardo en un treeIter Para utilizarlo como activo en el comboiBox
     foreach (IList row in queryResult.Rows) {
         TreeIter treeIter = listStore.AppendValues (row);
         if (row[0].Equals(id))
             treeIterAsignado = treeIter;
     }
     comboBox.Model = listStore;
     comboBox.SetActiveIter(treeIterAsignado);
 }
开发者ID:skounah,项目名称:2DAM-AD,代码行数:19,代码来源:ComboBoxHelper.cs

示例13: Fill

        public static void Fill(ComboBox combobox1, QueryResult queryresult, object id)
        {
            CellRendererText cellRendererText = new CellRendererText ();
            combobox1.PackStart (cellRendererText, false);

            combobox1.SetCellDataFunc (cellRendererText,
                            delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                IList row = (IList)tree_model.GetValue (iter, 0);
                cellRendererText.Text = row[1].ToString();
                    });
            ListStore listStore = new ListStore (typeof(IList));
            IList first=new object[]{null,"<sin asignar>"};
            TreeIter treeiterId=listStore.AppendValues (first);
            foreach (IList row in queryresult.Rows) {
                TreeIter treeiter=listStore.AppendValues (row);
                if (row[0].Equals(id))
                    treeiterId = treeiter;
            }
            combobox1.Model = listStore;
            //combobox1.Active = 0;
            combobox1.SetActiveIter (treeiterId);
        }
开发者ID:khadeon,项目名称:AD,代码行数:22,代码来源:ComboBoxHelper.cs

示例14: GenerateComboBoxSigning

        private void GenerateComboBoxSigning(ref Table table, string name, string label, string selectVal,int xPos,List<SettingValue> list)
        {
            xPos = xPos+3;
            Label lblApp = new Label(label);
            lblApp.Xalign = 1;
            lblApp.Yalign = 0.5F;
            lblApp.WidthRequest = 115;
            if(table.Name != "table1")
                lblApp.WidthRequest = 114;

            CellRendererText textRenderer = new CellRendererText();

            ComboBox cbe = new ComboBox();//(val);

            ListStore cbModel = new ListStore(typeof(string), typeof(string));

            cbe.PackStart(textRenderer, true);
            cbe.AddAttribute(textRenderer, "text", 0);

            cbe.Name = name;
            cbe.Model= cbModel;
            cbe.Active = 0;

            if(MainClass.Platform.IsMac){
                TreeIter ti = new TreeIter();

                foreach(SettingValue ds in list){// MainClass.Settings.InstallLocations){
                    if(ds.Value == selectVal){
                        ti = cbModel.AppendValues(ds.Display,ds.Value);
                        cbe.SetActiveIter(ti);
                    } else  cbModel.AppendValues(ds.Display,ds.Value);
                }
                if(cbe.Active <0)
                    cbe.Active =0;
            } else {
                cbe.Sensitive = false;
                if(!String.IsNullOrEmpty(selectVal)){
                    cbModel.AppendValues(selectVal,selectVal);
                    cbe.Active =0;
                } else {
                    Pango.FontDescription customFont =  Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont);
                    customFont.Weight = Pango.Weight.Bold;
                    cbe.ModifyFont(customFont);

                    cbModel.AppendValues("Please, don´t forget set the provisioning","");
                    cbe.Active =0;
                }
            }

            table.Attach(lblApp,0,1,(uint)(xPos-1),(uint)xPos,AttachOptions.Fill,AttachOptions.Shrink,0,0);
            table.Attach(cbe,1,2,(uint)(xPos-1),(uint)xPos,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Expand,0,0);
        }
开发者ID:moscrif,项目名称:ide,代码行数:52,代码来源:DevicePanel.cs

示例15: GenerateComboBox

        private void GenerateComboBox(ref Table table, string name, string label, string selectVal,int xPos,List<SettingValue> list,bool isAndroidSupportDevice)
        {
            xPos = xPos+3;
            Label lblApp = new Label(label);
            lblApp.Xalign = 1;
            lblApp.Yalign = 0.5F;
            lblApp.WidthRequest = 115;
            if(table.Name != "table1")
                lblApp.WidthRequest = 114;

            CellRendererText textRenderer = new CellRendererText();

            ComboBox cbe = new ComboBox();//(val);

            ListStore cbModel = new ListStore(typeof(string), typeof(string));

            cbe.PackStart(textRenderer, true);
            cbe.AddAttribute(textRenderer, "text", 0);

            cbe.Name = name;
            cbe.Model= cbModel;
            cbe.Active = 0;

            TreeIter ti = new TreeIter();

            foreach(SettingValue ds in list){// MainClass.Settings.InstallLocations){
                if(ds.Value == selectVal){
                    ti = cbModel.AppendValues(ds.Display,ds.Value);
                    cbe.SetActiveIter(ti);
                } else  cbModel.AppendValues(ds.Display,ds.Value);
            }
            if(cbe.Active <0)
                cbe.Active =0;
            if(isAndroidSupportDevice){
                cbe.Changed+= delegate(object sender, EventArgs e) {
                    if(cbe.Active !=0){
                        if(!MainClass.LicencesSystem.CheckFunction("androidsupporteddevices",parentWindow)){
                            cbe.Active =0;
                            return;
                        }
                    }
                };
            }

            table.Attach(lblApp,0,1,(uint)(xPos-1),(uint)xPos,AttachOptions.Fill,AttachOptions.Shrink,0,0);
            table.Attach(cbe,1,2,(uint)(xPos-1),(uint)xPos,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Expand,0,0);
        }
开发者ID:moscrif,项目名称:ide,代码行数:47,代码来源:DevicePanel.cs


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