0
I want to present the BD data in a table, but so far I could only do it using a ListView. How can I do it but using one DataGridView?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Driver.Linq;
namespace WFRecibos
{
public partial class frmListaClientes : Form
{
public frmListaClientes()
{
InitializeComponent();
}
public IEnumerable<Cliente> getTodosClientes()
{
var colClientes = DbHelper.getCollection("Cliente");
var clienteLista = from e in colClientes.AsQueryable<Cliente>() select e;
return clienteLista;
}
private void frmListaCli_Load(object sender, EventArgs e)
{
var consulta = this.getTodosClientes();
listView1.Items.Clear();
foreach (var cli in consulta)
{
listView1.Items.Add(cli.Nome);
listView1.Items.Add(cli.Municipio);
listView1.Items.Add(cli.Corrego);
}
}
private void gdvClientes_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}
You already have some code of this integration with Mongodb?
– Leonel Sanches da Silva
already have the drivers for C# and I have the query to Collection returning all customer data in a variable 'query'.
– henrique
@Edit your question and put the code you have using the
ListView, this makes it easier for other people to help you, you can follow the tips of that link– mateusalxd
entered my code... but today I was able to list the names of the 'columns' of Collection... only that did not return the data saved in DB
– henrique
@Enrique, I answered your question, regarding the problem you mentioned in the comments, create a new question to try to solve it, because I believe that this problem escapes from the original context of your question
– mateusalxd