Binding Object<T>
Bind contains an overload which takes an Object<T>
with T being any .Net object and builds the data grid from that object. The property names of the class become the column names. If there are alias set on the column, that will be used as the column header's. Example:
FIrst add a datagridview control to the form and set matching column header names:

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DGV.Framework;
namespace csDemo
{
public partial class Form1 : Form
{
public class User
{
public string Name { get; set; }
public int Age { get; set; }
public string Gender { get; set; }
}
public Form1()
{
InitializeComponent();
}
private void btnBindObject_Click(object sender, EventArgs e)
{
var user = new User()
{
Age = 28,
Gender = "Male",
Name = "John Doe"
};
_dataGridView.Bind(user);
}
}
}
Output:

Last updated
Was this helpful?