0
我是C#的新成员,并且想要使用datagridview,其中两个第一列的每次都是相同的,其余的依赖于字符串列表的内容。但我该怎么做?带变量列的Datagridview如何?
我的代码看起来是这样的,现在,我可以看到失败,但不知道该做些什么:(
PLZ帮我:)提前
View.Columns.Clear();
View.AutoGenerateColumns = false;
DataGridViewTextBoxColumn colTime = new DataGridViewTextBoxColumn();
colTime.DataPropertyName = "Time";
colTime.HeaderText = "Time";
colTime.Name = "Time";
colTime.Width = 55;
View.Columns.Add(colTime);
DataGridViewTextBoxColumn colPlace = new DataGridViewTextBoxColumn();
colPlace.DataPropertyName = "Place";
colPlace.HeaderText = "Place";
colPlace.Name = "Place";
colPlace.Width = 55;
View.Columns.Add(colPlace);
for(int i = 0; i < Liste.Length; i++)
{
DataGridViewCheckBoxColumn "Log"+List[i] = new DataGridViewCheckBoxColumn();
"Log"+List[i].DataPropertyName = "List[i]";
"Log"+List[i].HeaderText = "List[i]";
"Log"+List[i].Name = "List[i]";
"Log"+List[i].Width = 55;
View.Columns.Add("Log"+List[i]);
}
感谢
你想要只是动态创建datagridview?然后,您可以每次都将Col1和Col2设置为相同。 – 2014-09-29 18:26:12
是的,我想动态创建col 3 - x。当我开始的节目不知道很多col's需要。然后我想加载一个应该是col 3 -x名字的字符串列表。 – Hnox 2014-09-29 18:32:09