我有一个窗体与UserControl包含车辆列表的网格,我想传递车辆ID和颜色列表的方法,并在该方法中,我想查找每个车辆ID在数据源中的数据源索引。如何更改Devexpress网格行颜色无事件
这些索引我想要获得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++;
}
}
它的唯一原因,因为我不想在“加载时间”更改RowStyle,但我找到了解决方案与GridView.RefreshRow(int rowHandle)和处理RowStyle事件。谢谢 –