public void fillGridView() { string json = incometype.read(); if (!json.Equals("[]")) { dataGrid.DataSource = Tools.Util.convertToDataTable(json); dataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; this.dataGrid.Columns["active"].Visible = true; this.dataGrid.Columns["created_at"].Visible = false; this.dataGrid.Columns["updated_at"].Visible = false; this.dataGrid.Columns["__v"].Visible = false; this.dataGrid.Columns["_id"].Visible = false; dataGrid.Columns["number"].DisplayIndex = 0; dataGrid.Columns["number"].HeaderText = "Número"; dataGrid.Columns["description"].DisplayIndex = 1; dataGrid.Columns["description"].HeaderText = "Descripción"; dataGrid.Columns["description"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dataGrid.Columns["amount"].DisplayIndex = 2; dataGrid.Columns["amount"].HeaderText = "Monto"; dataGrid.Columns["amount"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dataGrid.Columns["active"].DisplayIndex = 3; dataGrid.Columns["active"].HeaderText = "Status"; } }
private void loadComboboxIncomeTypes() { Incometype incometype = new Incometype(); string json = incometype.read(); List <Incometype> x = JsonConvert.DeserializeObject <List <Incometype> >(json.Replace("_id", "id")); if (!json.Equals("[]")) { Dictionary <String, String> datasource = new Dictionary <string, string>(); foreach (Incometype p in x) { datasource.Add(p.Id, p.Description); } cmbTipoIngreso.DataSource = new BindingSource(datasource, null); cmbTipoIngreso.DisplayMember = "Value"; cmbTipoIngreso.ValueMember = "Key"; } }