Manually populating a DataGridView -- just can't get it to work

A

Alex

Hey Guys,

I'm sure there's a simple solution for this, but I'm not finding it.
I'm in VB 2005 and trying to manually populate a Data Grid View, not
using a datasource or anything.

I've added my dgv to the form and added the columns:
me.dgvPerson.Columns.Add("Name","Name")
me.dgvPerson.Columns.Add("Address","Address")
me.dgvPerson.Columns.Add("City","City")
me.dgvPerson.Columns.Add("State","State")
me.dgvPerson.Columns.Add("Zip","Zip")

And now i'm populating it by looping through a custom object stored in
a collection, so I'm doing a For Each through the collection and
manually inserting the values from the object into the dgv. Problem
is, since i'm not populating it from a datatable or dataset, I'm
having a heck of a time finding documentation showing how to add the
fields manually.

Suggestions?

Thanks --

Alex
 
S

Steve Gerrard

C

Cor Ligthert[MVP]

Alex,

Be aware from the showed page from Steve, that you give yourself a bunch of
work by populating (editing etc) it direct instead of using an OO Class like
the DataTable that can be used as the datasource.

Cor
 
R

RobinS

If you make a BindingList<YourObject>, you can directly bind it to the DGV
using a BindingSource.

RobinS.
 
C

Cor Ligthert [MVP]

Robin-

I thought that was stated "Manually", then there is in my idea no binding
source.

Any idea what I understand wrong?

-Cor
 
R

RobinS

I think he's loading the list manually, but that doesn't mean he has to load
the list into the grid manually. I was just offering him options, Cor. Why
would you load entries from a collection into a DGV manually? Ick.

RobinS.
GoldMail, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top