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); }
public static QueryResult Get(string selectText) { IDbConnection dbConnection = App.Instance.DbConnection; IDbCommand dbCommand = dbConnection.CreateCommand (); dbCommand.CommandText = selectText; IDataReader dataReader = dbCommand.ExecuteReader (); QueryResult queryResult = new QueryResult (); queryResult.ColumnNames = getColumnNames (dataReader); List<IList> rows = new List<IList> (); queryResult.Rows = rows; /// ListStore listStore = new ListStore(typeof(IList)); while (dataReader.Read()) { IList values = getValues (dataReader); listStore.AppendValues (values); rows.Add (values); } /// dataReader.Close (); return queryResult; }
public static void Fill(TreeView treeView, QueryResult queryResult) { removeAllColumns(treeView); string[] columnNames = queryResult.ColumnNames; CellRendererText cellRendererText = new CellRendererText(); for (int index = 0; index < columnNames.Length; index++) { int column = index; treeView.AppendColumn (columnNames [index], cellRendererText, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { IList row = (IList)tree_model.GetValue(iter, 0); //Si queremos que salga <vacio> en los campos que no haya nada pondremos: //if (row[column] == DBNull.Value) // cellRendererText.Text = "<vacio>"; //else cellRendererText.Text = row[column].ToString(); }); } ListStore listStore = new ListStore (typeof(IList)); foreach (IList row in queryResult.Rows) { listStore.AppendValues (row); } treeView.Model = listStore; }
public static void Fill(TreeView treeView, QueryResult queryResult) { string[] columnNames = queryResult.ColumnNames; CellRendererText cellRendererText = new CellRendererText (); for (int index = 0; index < columnNames.Length; index++) { int column = index; treeView.AppendColumn (columnNames [index], cellRendererText, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { IList row = (IList)tree_model.GetValue(iter, 0); cellRendererText.Text = row[column].ToString(); }); } ListStore listStore = new ListStore (typeof(IList)); foreach (IList row in queryResult.Rows) listStore.AppendValues (row); treeView.Model = listStore; }
public static QueryResult Get(string selectText) { IDbConnection dbConnection = App.Instance.DbConnection; IDbCommand dbCommand = dbConnection.CreateCommand (); dbCommand.CommandText = selectText; IDataReader dataReader = dbCommand.ExecuteReader (); QueryResult queryResult = new QueryResult (); queryResult.ColumnNames = getColumnNames (dataReader); List<IList> rows = new List<IList> (); while (dataReader.Read()) { IList row = getRow (dataReader); rows.Add (row); } queryResult.Rows = rows; dataReader.Close (); return queryResult; }
public static QueryResult Get(string selectText) { IDbConnection dbConnection = App.Instance.DbConnection; IDbCommand dbCommand = dbConnection.CreateCommand (); dbCommand.CommandText = selectText; IDataReader dataReader = dbCommand.ExecuteReader (); QueryResult queryResult = new QueryResult (); queryResult.ColumnNames = getColumnNames(dataReader); List<IList> rows = new List<IList> (); //rows.Add (new object[] { 1, "art. uno","1","1,5" }); Para añadir de forma manual while (dataReader.Read()) { IList row = getRows (dataReader); rows.Add (row); } queryResult.Rows=rows; dataReader.Close(); return queryResult; }
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); }
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); }
public static QueryResult Get(string selectText) { IDbConnection dbConnection = App.Instance.DbConnection; //Para conectarme IDbCommand dbCommand = dbConnection.CreateCommand (); //creo el dbcomando dbCommand.CommandText = selectText; //TODO completar QueryResult queryResult = new QueryResult (); //queryResult.ColumnNames = new string[] { "Columna 1", "Columna 2" }; IDataReader dataReader= dbCommand.ExecuteReader (); queryResult.ColumnNames= getColumnNames( dataReader); List<IList> rows = new List<IList> (); //rows.Add (new object[] { 1, "art. uno" }); //rows.Add (new object[] { 2, "art. dos" }); while (dataReader.Read()) rows.Add(getRow (dataReader)); queryResult.Rows = rows; return queryResult; }
public static void Fill(TreeView treeView , QueryResult queryResult) { removeAllColumns (treeView); string[] columnas = queryResult.ColumnNames; CellRendererText cellRendererText = new CellRendererText (); //añadimos columnas for (int i = 0; i < columnas.Length; i ++) { //otra manera de añadir columnas con un delegate int column = i; treeView.AppendColumn (columnas [i], cellRendererText, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { IList row = (IList)tree_model.GetValue(iter,0); cellRendererText.Text = row[column].ToString(); }); } ListStore listStore = new ListStore (typeof(IList)); foreach (IList row in queryResult.Rows) { listStore.AppendValues (row); } treeView.Model = listStore; }