6

これは、DevExpess XtraGrid の GridView に関連しています。

drilldown plus icon (+)ChildRow のデータを持たない GridView の MasterRow からを削除する必要があります。

現在、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:";
}

方向性や提案は大歓迎です。

前もって感謝します、

マーワン (^_^)

4

1 に答える 1

7

この DevExpress スレッドに従うことをお勧めします - How to hide disabled expand/collapse buttons for master rows without detail records

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;
    }
}

この助けを願っています..

于 2012-08-31T14:32:17.093 に答える