【发布时间】:2014-02-26 13:30:22
【问题描述】:
我的问题与此非常相似
但我不想创建数据表
这是网格视图
GridView = new RadGridView
{
AutoSizeRows = true,
BeginEditMode = RadGridViewBeginEditMode.BeginEditProgrammatically,
Location = new Point(0, 130),
Name = "GridView",
ShowRowErrors = false,
Size = new Size(390, 100),
TabIndex = 0,
Visible = false
};
此方法在运行时创建列
private List<GridViewTextBoxColumn> InitializeColumns()
{
var result = new List<GridViewTextBoxColumn>();
{
var columnId = new GridViewTextBoxColumn
{
Name = "RecordID",
HeaderText = "ID",
FieldName = "RecordID",
MaxLength = 50,
Width = 50,
DataType = typeof(int)
};
result.Add(columnId);
}
{
var columnInformation = new GridViewTextBoxColumn
{
Name = "RecordInformation",
HeaderText = "Information",
FieldName = "RecordInformation",
MaxLength = 50,
Width = 250,
DataType = typeof(string)
};
result.Add(columnInformation);
}
{
var columnRowType = new GridViewTextBoxColumn
{
Name = "RecordType",
HeaderText = "Type",
FieldName = "RecordType",
MaxLength = 50,
Width = 250,
DataType = typeof(string)
};
result.Add(columnRowType);
}
return result;
}
这个类用于网格行
internal class OrderTripChangedAlertItem
{
public int RecordID { get; set; }
public string RecordInformation { get; set; }
public string RecordType { get; set; }
public OrderTripChangedAlertItem(int recordID, string recordInformation, string recordType)
{
RecordID = recordID;
RecordInformation = recordInformation;
RecordType = recordType;
}
}
所以我将列表绑定到网格视图。列显示正常,但未显示数据。必须有一个记录。我错过了什么?
【问题讨论】:
标签: c# winforms gridview grid telerik