[英]data grid view not working
I have developed a form in c# which is called inside a console application. 我已经在c#中开发了一个在控制台应用程序内部称为表单的表单。
Below is how i have called the form inside the console. 下面是我如何在控制台内调用表单。
Application.Run(new Form1(display_list));
displaylist is a list of struct List , form_columns is a struct consisting of 3 string values which needs to be displayed side by side in a datagrid. displaylist是struct List的列表,form_columns是由3个字符串值组成的结构,需要在数据网格中并排显示。
Below is the constructor of the form 下面是表单的构造函数
public Form1(List<form_columns> disp)
{
InitializeComponent();
BindingSource source = new BindingSource();
source.DataSource = disp;
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = source;
}
But when the program is run , the datagridview is empty. 但是当程序运行时,datagridview为空。 it is not showing any data .
它没有显示任何数据。
What mistake am i making????? 我在犯什么错误?
Try to bind the list using BindingList 尝试使用BindingList绑定列表
BindingList<form_columns> bl = new BindingList<form_columns>(disp);
BindingSource source = new BindingSource(bl, null);
//source.DataSource = disp;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.