本文整理汇总了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 ();
}
示例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 ();
}
示例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);
}
示例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 ();
}
示例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);
}
示例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);
}
示例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);
};
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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 ();
}