这与DevExpess XtraGrid的GridView有关。
我需要从GridView中没有任何ChildRow数据的MasterRow中删除drilldown plus icon (+)
。
目前,我的GridView中的所有行(MasterRows)都显示drilldown plus icon (+)
。单击drilldown plus icon (+)
时,ChildRow将显示相应的数据。但是,如果ChildRow没有数据,则不会显示(展开)ChildRow。我需要使drilldown plus icon (+)
不可见,这样,如果ChildRow中没有数据,用户就看不到它。
我有一个函数,它检查ChildRow是否有可用的数据,然后允许ChildRow显示(展开)或不显示。
我使用了GridView.OptionsView.ShowDetailButtons
,但这会隐藏所有行上的drilldown plus icons (+)
。这对我来说不起作用,因为我只需要在没有ChildRow数据的情况下隐藏它。
这是我迄今为止的代码:
private void gridView1_MasterRowGetRelationCount(object sender, MasterRowGetRelationCountEventArgs e)
{
e.RelationCount = 1;
}
private void gridView1_MasterRowEmpty(object sender, MasterRowEmptyEventArgs e)
{
e.IsEmpty = IsRelationEmpty(e.RowHandle, e.RelationIndex);
}
bool IsRelationEmpty(int rowHandleX, int relationIndex)
{
Tuple<string, double, double> row = (Tuple<string, double, double>)gridView1.GetRow(rowHandleX);
return rowHandleX == DevExpress.XtraGrid.GridControl.InvalidRowHandle || _tfs._dataDictionary[row.Item1.ToString()].Item2.Count == 0;
}
private void gridView1_MasterRowGetChildList(object sender, MasterRowGetChildListEventArgs e)
{
if (IsRelationEmpty(e.RowHandle, e.RelationIndex))
{
return;
}
Tuple<string, double, double> row = (Tuple<string, double, double>)gridView1.GetRow(e.RowHandle);
e.ChildList = _tfs._dataDictionary[row.Item1.ToString()].Item2.ToList(); // _tfs.DictionaryToList();
}
private void gridView1_MasterRowGetRelationName(object sender, MasterRowGetRelationNameEventArgs e)
{
e.RelationName = "Work Items with no Size Estimate:";
}
任何指示或建议都将不胜感激。
提前感谢
Marwan(^_^)
我建议你遵循这个DevExpress线程-如何在没有详细记录的情况下隐藏主行禁用的扩展/折叠按钮
XtraGrid不提供隐藏主细节展开的选项用于空详细信息的按钮。您可以通过CustomDrawCell事件。
这是必要的代码:
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) {
GridView view = sender as GridView;
if(e.Column.VisibleIndex == 0 && view.IsMasterRowEmpty(e.RowHandle))
(e.Cell as GridCellInfo).CellButtonRect = Rectangle.Empty;
}
}
希望能帮上忙。。