0
我使用帶事件的devexpress xtragrid(C#winforms)將主要行動態綁定到詳細行。當我展開主要行時,我正在設置主要和詳細信息行的邊框。當主行被展開時,我想要一行藍色框與其明細行一起使用,以使它突出顯示給用戶。圍繞展開的行設置邊框
我使用帶事件的devexpress xtragrid(C#winforms)將主要行動態綁定到詳細行。當我展開主要行時,我正在設置主要和詳細信息行的邊框。當主行被展開時,我想要一行藍色框與其明細行一起使用,以使它突出顯示給用戶。圍繞展開的行設置邊框
您可以使用該方法的基礎上,處理GridControl.Paint
事件完成任務:
gridControl1.DataSource = Repository.GetOrders();
// Some Visual Options for details
gridView1.LevelIndent = 0;
gridView1.OptionsDetail.ShowDetailTabs = false;
gridView1.OptionsDetail.AllowOnlyOneMasterRowExpanded = true;
//
gridControl1.Paint += gridControl1_Paint;
//...
void gridControl1_Paint(object sender, PaintEventArgs e) {
var viewInfo = gridView1.GetViewInfo() as GridViewInfo;
foreach(var rowInfo in viewInfo.RowsInfo) {
if(gridView1.GetMasterRowExpanded(rowInfo.RowHandle))
e.Graphics.DrawRectangle(Pens.Blue, rowInfo.TotalBounds);
}
}
數據類:
public static class Repository {
public static List<Order> GetOrders() {
return new List<Order> {
new Order(){ Id=0, Date = DateTime.Now.AddDays(-1),
Items = new List<OrderItem>{
new OrderItem(){ Id=0, Name="A"},
new OrderItem(){ Id=1, Name="B"},
}
},
new Order(){ Id=1, Date = DateTime.Now,
Items = new List<OrderItem>{
new OrderItem(){ Id=0, Name="A"},
new OrderItem(){ Id=1, Name="B"},
new OrderItem(){ Id=1, Name="C"},
}
}
};
}
}
public class Order {
public int Id { get; set; }
public DateTime Date { get; set; }
public List<OrderItem> Items { get; set; }
}
public class OrderItem {
public int Id { get; set; }
public string Name { get; set; }
}