hello... i just want to ask for help on how to add or retrieve data in datagrid... in my case, i have my data and im just going to output it in datagrid view.... plz help me guys...

Recommended Answers

All 2 Replies

I find the easiest way to use a DataGridView is with databinding. If you store your data in a DataSet or DataTable you can bind it to the DataGridView using it's DataSource property.

as privatevoid says, the datasource is the easiest way:

DataTable dt = new DataTable();
//populate datatable with data
DataGridView1.DataSource = dt;

Easy as that :p

Retrieving data from the datagridview you can either pull the datasource out and work with that DataTable dat = (DataTable)dataGridView1.DataSource; or access the datagridview cells by index

dataGridView1[columnIndex, rowIndex].Value;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.