
我需要从GrIDVIEw中的任何MasterRow中删除drilldown plus icon(),该GrIDVIEw没有任何ChildRow数据.
目前,我的GrIDVIEw中的所有行(MasterRows)都显示了drilldown plus icon().单击向下钻取加上icon()时,将显示带有相应数据的ChildRow.但是,如果ChildRow没有数据,则不显示(扩展)ChildRow.我需要使钻取加上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>)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>)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线程 – How to hide disabled expand/collapse buttons for master rows without detail recordsThe XtraGrID does not provIDe an option to hIDe master-detail expand
buttons for empty details. You can work around this limitation via the
CustomDrawCell event.
这是必要的代码:
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; }} 希望这有帮助..
总结以上是内存溢出为你收集整理的c# – 当ChildRow没有数据时从XtraGrid GridView的MasterRow中删除Drilldown Plus图标()全部内容,希望文章能够帮你解决c# – 当ChildRow没有数据时从XtraGrid GridView的MasterRow中删除Drilldown Plus图标()所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)