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

  • Thread starter Thread starter Alex
  • Start date Start date
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
 
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
 
If you make a BindingList<YourObject>, you can directly bind it to the DGV
using a BindingSource.

RobinS.
 
Robin-

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

Any idea what I understand wrong?

-Cor
 
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.
 
Back
Top