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


C# ComboBox.AddAttribute方法代码示例

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


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

示例1: ComboBoxDialog

		public ComboBoxDialog()
		{
			Title = "Gtk Combo Box Dialog";
			WidthRequest = 500;
			HeightRequest = 400;

			var vbox = new VBox ();
			this.VBox.PackStart (vbox);

			comboBox = new ComboBox ();
			vbox.PackStart (comboBox, false, false, 0);

			listStore = new ListStore (typeof(string), typeof(ComboBoxItem));
			comboBox.Model = listStore;

			var cell = new CellRendererText ();
			comboBox.PackStart (cell, true);
			comboBox.AddAttribute (cell, "text", 0);

			AddItems ();

			Child.ShowAll ();

			Show ();
		}
开发者ID:mrward,项目名称:test-xwt-memory-leak,代码行数:25,代码来源:ComboBoxDialog.cs

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

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

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

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

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

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

示例8: DropDownView

 /// <summary>Constructor</summary>
 public DropDownView(ViewBase owner)
     : base(owner)
 {
     combobox1 = new ComboBox(comboModel);
     _mainWidget = combobox1;
     combobox1.PackStart(comboRender, false);
     combobox1.AddAttribute(comboRender, "text", 0);
     combobox1.Changed += OnSelectionChanged;
     _mainWidget.Destroyed += _mainWidget_Destroyed;
 }
开发者ID:hol353,项目名称:ApsimX,代码行数:11,代码来源:DropDownView.cs

示例9: FillSizeCombo

 public static void FillSizeCombo(ComboBox combo, string[] sizes)
 {
     combo.Clear ();
     var list = new ListStore (typeof(string));
     foreach (var size in sizes)
         list.AppendValues (size);
     combo.Model = list;
     CellRendererText text = new CellRendererText ();
     combo.PackStart (text, true);
     combo.AddAttribute (text, "text", 0);
 }
开发者ID:QualitySolution,项目名称:workwear,代码行数:11,代码来源:SizeHelper.cs

示例10: ColourDropDownView

 /// <summary>Constructor</summary>
 public ColourDropDownView(ViewBase owner)
     : base(owner)
 {
     combobox1 = new ComboBox(comboModel);
     _mainWidget = combobox1;
     combobox1.PackStart(comboRender, true);
     combobox1.AddAttribute(comboRender, "text", 0);
     combobox1.SetCellDataFunc(comboRender, OnDrawColourCombo);
     combobox1.Changed += OnChanged;
     _mainWidget.Destroyed += _mainWidget_Destroyed;
 }
开发者ID:hol353,项目名称:ApsimX,代码行数:12,代码来源:ColourDropDownView.cs

示例11: CreateComboBox

		protected override ComboBox CreateComboBox ()
		{
			var box = new ComboBox ();

			cell_renderer = new CellRendererText ();

			box.PackStart (cell_renderer, false);
			box.AddAttribute (cell_renderer, "text", 0);
			box.SetCellDataFunc (cell_renderer, new CellLayoutDataFunc (RenderFont));

			return box;
		}
开发者ID:RudoCris,项目名称:Pinta,代码行数:12,代码来源:ToolBarFontComboBox.cs

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

示例13: FeedbackControl

        public FeedbackControl(TypFeedback type)
            : base(3,2,false)
        {
            typeFeedback = type;
            this.RowSpacing = 3;
            this.ColumnSpacing = 3;
            Label lblSubject =  GetLabel("Subject");
            this.Attach(lblSubject,0,1,0,1,AttachOptions.Fill,AttachOptions.Fill,0,0);

            entrSubject  = new Entry();
            this.Attach(entrSubject,1,2,0,1,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0);

            cbType = new ComboBox();
            projectModel = new ListStore(typeof(string), typeof(string));
            CellRendererText textRenderer = new CellRendererText();
            cbType.PackStart(textRenderer, true);
            cbType.AddAttribute(textRenderer, "text", 0);
            cbType.Model= projectModel;
            projectModel.AppendValues("IDE and Emulator","IDE and Emulator" );
            projectModel.AppendValues("Framework and Documentation","Framework and Documentation" );
            projectModel.AppendValues("Deployment, Devices and Publishing","Deployment, Devices and Publishing" );
            projectModel.AppendValues("Web moscrif.com","Web moscrif.com" );
            cbType.Active = 0;

            Label lblVersion =  GetLabel("Product Group");
            this.Attach(lblVersion,0,1,1,2,AttachOptions.Fill,AttachOptions.Fill,0,0);
            this.Attach(cbType,1,2,1,2,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0);

            Label lblDescription =  GetLabel("Description");
            this.Attach(lblDescription,0,1,2,3,AttachOptions.Fill,AttachOptions.Fill,0,0);

            tvDescription = new TextView();
            ScrolledWindow sw = new ScrolledWindow ();
            sw.ShadowType = ShadowType.Out;
            sw.Add(tvDescription);

            this.Attach(sw,1,2,2,3,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill|AttachOptions.Expand,0,0);

            this.ShowAll();
        }
开发者ID:moscrif,项目名称:ide,代码行数:40,代码来源:FeedbackControl.cs

示例14: PropertyGrid

        public PropertyGrid(ServiceContainer parentServices)
        {
            this.parentServices = parentServices;

            grid = new AspNetEdit.UI.PropertyGrid ();
            this.PackEnd (grid, true, true, 0);

            components = new ListStore (typeof (string), typeof (IComponent));
            combo = new ComboBox (components);

            CellRenderer rdr = new CellRendererText ();
            combo.PackStart (rdr, true);
            combo.AddAttribute (rdr, "text", 0);

            this.PackStart (combo, false, false, 3);

            //for selecting nothing, i.e. deselect all
            components.AppendValues (new object[] { "", null} );

            combo.Changed += new EventHandler (combo_Changed);

            InitialiseServices();
        }
开发者ID:mono,项目名称:aspeditor,代码行数:23,代码来源:PropertyGrid.cs

示例15: TimePeriodAdderView

        public TimePeriodAdderView(Glade.XML gxml)
        {
            startTimeEntry = (Gtk.Entry)gxml.GetWidget ("startTimestampEntry");
            endTimeEntry = (Gtk.Entry)gxml.GetWidget ("endTimestampEntry");
            blockCommentTextview = (Gtk.TextView)gxml.GetWidget ("blockCommentTextview");
            addBlockButton = (Gtk.Button)gxml.GetWidget ("addBlockButton");
            cancelBlockButton = (Gtk.Button)gxml.GetWidget ("cancelBlockButton");
            startBlockButton = (Gtk.Button)gxml.GetWidget ("startBlockButton");

            taskCombobox = (Gtk.ComboBox)gxml.GetWidget ("taskCombobox");

            Gtk.CellRendererText colCell = new Gtk.CellRendererText ();

            taskCombobox.PackStart (colCell, false);

            taskTree = new Gtk.TreeStore (typeof(string));

            taskCombobox.AddAttribute (colCell, "text", 0);

            taskCombobox.Model = taskTree;

            notDefiningBlockSensitivity ();
        }
开发者ID:simon-g-crosby,项目名称:time-track-client,代码行数:23,代码来源:TimePeriodAdderView.cs


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