Hi Patrik,
DataGridView can only support complex data binding, so it is impossible for
us to bind a cell in a DataGridView to a data source separately.
In my opinion, you have two options to get what you want.
One option is to fill the data into the cells within the DataGridView by
yourself. The following is a sample.
this.dataGridView1.RowCount = 3;
this.dataGridView1.ColumnCount = 2;
this.dataGridView1.Rows[0].Cells[0].Value = "par1.name";
this.dataGridView1.Rows[0].Cells[1].Value = "par1.value";
this.dataGridView1.Rows[1].Cells[0].Value = "par2.name";
this.dataGridView1.Rows[1].Cells[1].Value = "par2.value";
this.dataGridView1.Rows[2].Cells[0].Value = "par3.name";
this.dataGridView1.Rows[2].Cells[1].Value = "par3.value";
When you'd like to update the data in the DataGridView, you have to update
it by yourself.
The other option is to make use of a DataTable, which has two columns(one
column is fo r the property name and the other column is for property
value) and contains the names and values of all the properties of your
business object. You could then bind the DataGridView to the DataTable.
When you'd like to update the data in the DataGridView, you could just
update the data in the DataTable, and data binding will update the data in
the DataGridView automatically.
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.