【发布时间】:2014-09-17 10:51:10
【问题描述】:
我有一个包含车辆列表网格的 UserControl 表单,我想将车辆 ID 列表和颜色传递给方法,在该方法中,我想找到车辆 ID 所在的数据源的每个索引在数据源中。
通过这些索引,我想获取 RowHandle(或直接是行对象)并使用我在参数中传递的颜色更改背景色。
private void ApplyColorRow(List<int> vehicleID, Color color)
{
var Index = 0;
// foreach view the Datasource
foreach (var View in this.VehicleViewList)
{
// if the list of VehicleID contains the vehicleID
if (vehicleID.Contains(View.VehicleData.VehicleID))
{
// find the Row handle corresping to the datasource index
var RowHandle = this.gvVehicle.GetRowHandle(Index);
// Get the row object
// This return an object corresponding to the View (VehicleView in my case)
// But I need the Row object to change the appearance.
var Row = this.gvVehicle.GetRow(RowHandle);
// Row.BackColor = color;
}
Index++;
}
}
【问题讨论】:
标签: c# winforms visual-studio devexpress