如果列数不是const,如何绑定ListView?这是我需要绑定的表类:
public class Table
{
public string TableName { get; set; }
public List<TableColumn> Columns { get; set; }
}
public class TableColumn
{
public string ColumnName { get; set; }
public string ColumnType { get; set; }
public List<Object> Values { get; set; }
}
示例:
Table myTable = new MyTable();
TableColumn column1 = new TableColumn();
column1.Name ="MyColumn1";
column1.Values.Add("val1_col1");
column1.Values.Add("val2_col1");
column1.Values.Add("val3_col1");
TableColumn column2 = new TableColumn();
column2.Name ="MyColumn2";
column2.Values.Add("val1_col2");
column2.Values.Add("val2_col2");
myTable.Columns.Add(column1);
myTable.Columns.Add(column2);
//So, the ListView should be viewed like:
MyColumn1 MyColumn2
val1_col1 val1_col2
val2_col1 val2_col2
val3_col1 null
答案 0 :(得分:0)
尝试将您的数据放入System.Data.DataTable
并绑定到该数据。