In my Winform
C#
application I have a DataGridView
that bound with DataTable
and have many records.
I want to display details of the selected row (of DataGridView
) in the following Format (see Image).What Control
or (Trick) should I use to achieve this.
In other words: “First Column of the Table should have Columns name and 2nd Column should have its corresponding values”
Typically, I wouldn't do this in a DataGridView, its really intended to display multiple records and you only want to display one record at a time. I can suggest two alternate ways of dealing with this:
The typical approach if you know the fields to be displayed ahead of time would be to lay out a set of individual value displaying labels and other simple controls at design time. This has the following advantages:
If you don't know the fields to be displayed at design time, or don't want to bother laying them out, use a PropertyGrid control instead of a DataGridView. I've never actually tried this with a DataTable as a data source, but it looks like there is a well developed answer for that at C#/winforms: how to best bind a propertygrid and a System.Data.DataRow