本文整理汇总了C#中Gtk.ComboBox.PackStart方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.PackStart方法的具体用法?C# ComboBox.PackStart怎么用?C# ComboBox.PackStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ComboBox
的用法示例。
在下文中一共展示了ComboBox.PackStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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 ();
}
示例3: 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 ();
}
示例4: 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 ();
}
示例5: 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);
}
示例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, 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);
}
示例8: 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;
}
示例9: 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);
}
示例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);
};
}
示例11: 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;
}
示例12: 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;
}
示例13: 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);
}
示例14: 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;
}
示例15: Fill
public static void Fill(ComboBox combobox, QueryResult queryResult)
{
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));
foreach (IList row in queryResult.Rows)
listStore.AppendValues (row);
combobox.Model = listStore;
}