In C# Winforms DataGridView
I am binding a List of class using the datagriview's datasource
property. Is there a way to bind one of the class property to the datagriview's rowheader
?
I didn't want to iterate
all the rows and add row header values one by one because I will have thousands of records so I wanted the rowheader to get the values from the binded class when I set the datasource.
For example I have this class and I want the rowheaders to show the Customer ID.
private class Customer
{
public string CustomerID { get; set; }
public string CustomerFirstName { get; set; }
}
I'm afraid you have to implement datagridview's OnPaint
-Method, where you paint the customer id in a loop. Once, I wanted to numerate my entries and I didn't find any other solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.