本文整理汇总了C#中Gtk.ListStore.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ListStore.GetValue方法的具体用法?C# ListStore.GetValue怎么用?C# ListStore.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
mySqlConnection.Open();
MySqlCommand mySqlCommand=mySqlConnection.CreateCommand();
mySqlCommand.CommandText= "select * from categoria";
MySqlDataReader mysqlDataReader= mySqlCommand.ExecuteReader();
int fieldcount=mysqlDataReader.FieldCount;
creaColumnas(fieldcount,mysqlDataReader);
ListStore listStore=new ListStore(creaTipos(fieldcount));
rellenar(fieldcount,listStore,mysqlDataReader);
mysqlDataReader.Close();
removeAction.Sensitive=false;
treeView.Model=listStore;
TreeIter iter;
treeView.Selection.Changed+=delegate{
bool isSelected=treeView.Selection.GetSelected(out iter);
if(isSelected)
removeAction.Sensitive=true;
else
removeAction.Sensitive=false;
};
removeAction.Activated +=delegate{
string nombre=listStore.GetValue(iter,1).ToString();
MessageDialog md2 = new MessageDialog
(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,"¿Seguro que quieres borrarlo? \n Borrar: "+nombre);
ResponseType result = (ResponseType)md2.Run ();
string op=listStore.GetValue(iter,0).ToString();
if (result == ResponseType.Yes){
MySqlCommand delete=mySqlConnection.CreateCommand();
delete.CommandText= "Delete from categoria where id="+op+"";
delete.ExecuteNonQuery();
md2.Destroy();
for (int i=0;i<fieldcount;i++){//elimina columnas
treeView.RemoveColumn(treeView.GetColumn(0));
}
listStore.Clear();//vacia el modelo
//volvemos a mostrar treview actualizado
actualizar(mySqlCommand,listStore);
}
else{
md2.Destroy();
}
};
}
示例2: SaveList
public static void SaveList(ListStore list, string path)
{
path = path + "streams.list";
File.Delete(path);
for (int i = 0; i < list.IterNChildren(); i++) {
TreeIter iter;
list.GetIterFromString (out iter, i.ToString ());
File.AppendAllText(path, list.GetValue(iter, 0).ToString());
File.AppendAllText(path, " ");
File.AppendAllText(path, list.GetValue(iter, 1).ToString());
File.AppendAllText(path, "\n");
}
}
示例3: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
treeView.Selection.Mode = SelectionMode.Multiple;//seleccion multiple de item
treeView.AppendColumn("Columna uno",new CellRendererText(),"text",0);
treeView.AppendColumn("Columna dos",new CellRendererText(),"text",1);
treeView.AppendColumn("Columna tres",new CellRendererText(),"text",2);
ListStore listStore = new ListStore(typeof(string), typeof(string), typeof(string));
treeView.Model = listStore;
listStore.AppendValues("clave uno", "valor uno", "uno");
listStore.AppendValues("clave dos", "valor dos", "dos");
listStore.AppendValues("clave tres", "valor tres", "tres");
listStore.AppendValues("clave cuatro", "valor cuatro", "cuatro");
treeView.Selection.Changed += delegate {//añade la ocurrencia del metodo al evento
int count = treeView.Selection.CountSelectedRows();
Console.WriteLine("treeView.Selection.Changed CountSelectedRows={0}", count);
treeView.Selection.SelectedForeach(delegate(TreeModel model, TreePath path, TreeIter iter)
{
object value = listStore.GetValue(iter, 0);
Console.WriteLine("value={0}", value);
});
};
}
示例4: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
//comboBox.Active = 0; -> Para establecer como predeterminado un item del combo
CellRenderer cellRenderer = new CellRendererText();
comboBox.PackStart(cellRenderer, false); //expand = false
comboBox.AddAttribute(cellRenderer, "text", 0);
CellRenderer cellRenderer2 = new CellRendererText();
comboBox.PackStart(cellRenderer2, false); //expand = false
comboBox.AddAttribute(cellRenderer2, "text", 1);
listStore = new ListStore(typeof(string), typeof(string));
comboBox.Model = listStore;
listStore.AppendValues("1", "uno");
listStore.AppendValues("2", "dos");
comboBox.Changed += comboBoxChanged;
comboBox.Changed += delegate {showItemSelected(listStore);};
comboBox.Changed += delegate {
Console.WriteLine("Evento activado");
TreeIter treeIter;
if (comboBox.GetActiveIter(out treeIter) ){ // item seleccionado.
object value =listStore.GetValue(treeIter, 0);
Console.WriteLine("ComboBox.changed id={0}", value);
}
};
}
示例5: showActiveItem
private void showActiveItem(ListStore listStore)
{
TreeIter treeIter;
if ( comboBox.GetActiveIter (out treeIter) ) { //item seleccionado
object value = listStore.GetValue (treeIter, 0);
Console.WriteLine ("comboBox.Changed delegate value={0}", value);
}
}
示例6: showItemSelected
private void showItemSelected(ListStore listStore)
{
Console.WriteLine("Evento activado");
TreeIter treeIter;
if (comboBox.GetActiveIter(out treeIter) ){
object value =listStore.GetValue(treeIter, 0);
Console.WriteLine("ComboBoxChanged id={0}", value);
}
}
示例7: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
// MyFunction f;
//
// MyFunction[] functions = new MyFunction[]{suma, resta, multiplica};
//
// int random = new Random().Next(3);
// f= functions[random];
//
// Console.WriteLine("f={0}", f(5,3));
treeView.Selection.Mode=SelectionMode.Multiple;
treeView.AppendColumn("Columna uno", new CellRendererText(), "text",0);
treeView.AppendColumn("Columna dos", new CellRendererText(), "text",1);
CellRenderer cellRenderer = new CellRendererText();
comboBox.PackStart(cellRenderer, false); //expand = false
comboBox.AddAttribute (cellRenderer, "text", 0);
CellRenderer cellRenderer2 = new CellRendererText();
comboBox.PackStart(cellRenderer2, false); //expand = false
comboBox.AddAttribute (cellRenderer2, "text", 1);
listStore = new ListStore (typeof(string), typeof(string));
comboBox.Model = listStore;
treeView.Model = listStore;
listStore.AppendValues("1", "Uno");
listStore.AppendValues("2", "Dos");
treeView.Selection.Changed+=delegate{
int count = treeView.Selection.CountSelectedRows();
Console.WriteLine("treeView.Selection.Changed CountSelectedRows={0}" + count);
treeView.Selection.SelectedForeach(delegate(TreeModel model, TreePath path, TreeIter iter){
object value = listStore.GetValue(iter, 0);
Console.WriteLine("value={0}", value);
});
};
// comboBox.Changed += delegate {
// TreeIter treeIter;
// if(comboBox.GetActiveIter(out treeIter)){ //Item seleccionado
// object value = listStore.GetValue (treeIter, 0);
// Console.WriteLine("comboBoxChanged value={0}", value);
// }
// };
comboBox.Changed += comboBoxChanged;
//comboBox.Changed += delegate {showActiveItem (listStore); };
}
示例8: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
treeView.AppendColumn ("id", new CellRendererText (), "text", 0);
treeView.AppendColumn ("nombre", new CellRendererText(), "text", 1);
ListStore listStore = new ListStore(typeof(long), typeof(string));
treeView.Model = listStore;
//liststore.AppendValues (33L, "Treinta y tres");
App.Instance.DbConnection = new MySqlConnection ("Database=dbprueba;user=root;password=sistemas");
App.Instance.DbConnection.Open ();
fillListStore (listStore);
newAction.Activated += delegate {
CCategoria.CategoriaView categoriaView = new CCategoria.CategoriaView();
};
deleteAction.Activated += delegate {
if (!WindowHelper.Confirm(this, "Quieres eliminar el registro?")){
return;
}
TreeIter treeIter;
treeView.Selection.GetSelected(out treeIter);
object id = listStore.GetValue(treeIter,0);
Console.WriteLine ("deleteAction Activated id = {0}" , id);
IDbCommand deleteDbCommand = App.Instance.DbConnection.CreateCommand();
//TODO usar dbParameters para el id
deleteDbCommand.CommandText = "delete from categoria where id = @id";
DbHelper.DbCommandAddParameter(deleteDbCommand, "id", id);
deleteDbCommand.ExecuteNonQuery();
};
refreshActions.Activated += delegate {
fillListStore (listStore);
};
treeView.Selection.Changed += delegate {
Console.WriteLine ("treeView Selection Changed CountSelectedRows()={0}",
treeView.Selection.CountSelectedRows());
refreshAction();
};
//dbConnection.Close ();
}
示例9: Delete
public static void Delete (TreeView treeView,ListStore listStore,IDbConnection dbConnection,String sql){
TreeIter treeIter;
treeView.Selection.GetSelected (out treeIter);
object id = listStore.GetValue (treeIter, 0);
string deleteSql = string.Format (sql, id);
IDbCommand dbCommand = dbConnection.CreateCommand ();
dbCommand.CommandText = deleteSql;
dbCommand.ExecuteNonQuery ();
}
示例10: BuildWidget
private void BuildWidget ()
{
store = new ListStore (typeof (string), typeof (EqualizerSetting));
Model = store;
TextColumn = 0;
store.DefaultSortFunc = (model, ia, ib) => {
var a = GetEqualizerSettingForIter (ia);
var b = GetEqualizerSettingForIter (ib);
if (a != null && b != null) {
return a.IsReadOnly == b.IsReadOnly
? a.Name.CompareTo (b.Name)
: a.IsReadOnly.CompareTo (b.IsReadOnly);
} else if (a == null && b == null) {
return 0;
} else if ((a == null && b.IsReadOnly) || (b == null && !a.IsReadOnly)) {
return -1;
} else if ((a == null && !b.IsReadOnly) || (b == null && a.IsReadOnly)) {
return 1;
}
return 0;
};
store.SetSortColumnId (-1, SortType.Ascending);
RowSeparatorFunc = (model, iter) =>
store.GetValue (iter, 0) as String == String.Empty &&
store.GetValue (iter, 1) == null;
foreach (EqualizerSetting eq in manager) {
AddEqualizerSetting(eq);
}
manager.EqualizerAdded += (o, e) => AddEqualizerSetting (e.Value);
manager.EqualizerRemoved += (o, e) => RemoveEqualizerSetting (e.Value);
}
示例11: RestoreBackupDialog
public RestoreBackupDialog(Gtk.Window parent)
: base("Saves", parent)
{
this.IconName = "document-revert";
XML gxml = new XML(null, "MultiMC.GTKGUI.RestoreBackupDialog.glade", "restoreRoot", null);
gxml.Toplevel = this;
gxml.Autoconnect(this);
this.VBox.PackStart(restoreRoot);
this.WidthRequest = 620;
this.HeightRequest = 380;
// set default button states
btnCancel.Sensitive = true;
btnOK.Sensitive = false;
// FIXME: store date/time properly so ordering works.
backupsStore = new ListStore(typeof(string), typeof(DateTime), typeof(string), typeof(string));
restoreView.Model = backupsStore;
restoreView.AppendColumn("Backup name", new CellRendererText(), "text", 0);
restoreView.AppendColumn("Date", new CellRendererText(), new TreeCellDataFunc(DateTimeCell));
restoreView.AppendColumn("Hash", new CellRendererText(), "text", 2);
restoreView.Selection.Mode = SelectionMode.Single;
// this binds view and model columns together for sorting
restoreView.Columns[0].SortColumnId = 0;
restoreView.Columns[1].SortColumnId = 1;
restoreView.Columns[2].SortColumnId = 2;
// the date column needs a custom sorting function that can compare DateTime objects
backupsStore.SetSortFunc(1,new TreeIterCompareFunc(DateTimeTreeIterCompareFunc));
backupsStore.SetSortColumnId(1,SortType.Ascending); // sort by date
restoreView.Selection.Changed += (sender, e) =>
{
if(restoreView.Selection.CountSelectedRows() != 0)
{
btnOK.Sensitive = true;
TreeIter iter;
restoreView.Selection.GetSelected(out iter);
currentHash = backupsStore.GetValue(iter,3) as string;
}
else
{
btnOK.Sensitive = false;
}
};
ShowAll();
}
示例12: GitConfigurationDialog
public GitConfigurationDialog (GitRepository repo)
{
this.Build ();
this.repo = repo;
this.HasSeparator = false;
// Branches list
storeBranches = new ListStore (typeof(Branch), typeof(string), typeof(string), typeof(string));
listBranches.Model = storeBranches;
listBranches.HeadersVisible = true;
listBranches.AppendColumn (GettextCatalog.GetString ("Branch"), new CellRendererText (), "markup", 1);
listBranches.AppendColumn (GettextCatalog.GetString ("Tracking"), new CellRendererText (), "text", 2);
listBranches.Selection.Changed += delegate {
TreeIter it;
if (!listBranches.Selection.GetSelected (out it))
return;
string currentBranch = repo.GetCurrentBranch ();
var b = (Branch) storeBranches.GetValue (it, 0);
buttonRemoveBranch.Sensitive = b.Name != currentBranch;
};
// Sources tree
storeRemotes = new TreeStore (typeof(RemoteSource), typeof(string), typeof(string), typeof(string), typeof(string));
treeRemotes.Model = storeRemotes;
treeRemotes.HeadersVisible = true;
treeRemotes.AppendColumn ("Remote Source / Branch", new CellRendererText (), "markup", 1);
treeRemotes.AppendColumn ("Url", new CellRendererText (), "text", 2);
// Tags list
storeTags = new ListStore (typeof(string));
listTags.Model = storeTags;
listTags.HeadersVisible = true;
listTags.AppendColumn (GettextCatalog.GetString ("Tag"), new CellRendererText (), "text", 0);
// Fill data
FillBranches ();
FillRemotes ();
FillTags ();
}
示例13: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
Build ();
MyFunction f;
MyFunction[] functions = new MyFunction[]{suma, resta, multiplica};
int random = new Random().Next(3);
f = functions[random];
// if (new Random().Next(2) ==0){
// f=suma;
// }
// else{
// f=resta;
// }
Console.WriteLine("f={0}", f(5,3));
//comboBox
CellRenderer cellRenderer = new CellRendererText();
combobox.PackStart(cellRenderer, false);
combobox.AddAttribute (cellRenderer, "text", 1);
listStore = new ListStore(typeof(string), typeof(string));
combobox.Model = listStore;
listStore.AppendValues("1", "Uno");
listStore.AppendValues("2", "Dos");
listStore.AppendValues("3", "Tres");
listStore.AppendValues("4", "Cuatro");
listStore.AppendValues("5", "Cinco");
combobox.Changed += delegate {
TreeIter treeIter;
if (combobox.GetActiveIter (out treeIter)) { //item seleccionado
object value = listStore.GetValue(treeIter, 0);
Console.WriteLine ("ComboBox.Changed delegate id={0}", value);
}
};
combobox.Changed += comboBoxChanged;
}
示例14: EditModsDialog
public EditModsDialog(Instance inst, Gtk.Window parent = null)
: base("Edit Mods", parent, DialogFlags.Modal)
{
Inst = inst;
this.Build();
#region We have to make the treeview ourselves since monodevelop is absolute shit...
this.editModScroll = new ScrolledWindow();
this.editModScroll.HscrollbarPolicy = PolicyType.Never;
this.modView = new Gtk.TreeView();
this.modView.CanFocus = true;
this.modView.Name = "modView";
this.editModScroll.Add(this.modView);
this.VBox.Add(this.editModScroll);
Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.VBox[this.editModScroll]));
w3.Position = 0;
this.ShowAll();
#endregion
modList = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(DateTime));
modView.Model = modList;
modView.AppendColumn("File", new CellRendererText(), "text", 0);
modView.AppendColumn("Install Date", new CellRendererText(), "text", 1);
CellRendererToggle toggleRenderer = new CellRendererToggle();
toggleRenderer.Activatable = true;
toggleRenderer.Sensitive = true;
toggleRenderer.Toggled += (object o, ToggledArgs args) =>
{
TreeIter iter;
if (modList.GetIter(out iter, new TreePath(args.Path)))
modList.SetValue(iter, 2, !(bool)modList.GetValue(iter, 2));
};
modView.AppendColumn("Delete?", toggleRenderer, "active", 2);
modView.Columns[0].Alignment = 0.0f;
modView.Columns[0].Expand = true;
modView.Columns[1].Alignment = 1.0f;
modView.Columns[2].Alignment = 1.0f;
LoadMods();
}
示例15: 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);
};
}