[英]How can I find the last row of a group in a DevExpress gridview?
我有一個gridview,里面有很多組。 我還具有向上/向下按鈕,可以向上/向下移動組內的數據行。 如果數據行是組中的最后一行,那么當用戶按下“向下”按鈕時,我不希望該行執行任何操作。 如何查看數據行是否為組中的最后一行?
你可以試試這個
int rowHandle = view.FocusedRowHandle;
int groupRow = view.GetParentRowHandle(rowHandle);
var childRows = GetChildRowsHandles(view, groupRow);
if (childRows.Count > 0 && childRows.Last() == rowHandle)
{
//selected row is the last datarow of its GroupRow
}
public List<int> GetChildRowsHandles(GridView view, int groupRowHandle)
{
List<int> childRows = new List<int>();
if (!view.IsGroupRow(groupRowHandle))
{
return childRows;
}
int childCount = view.GetChildRowCount(groupRowHandle);
for (int i = 0; i < childCount; i++)
{
int childHandle = view.GetChildRowHandle(groupRowHandle, i);
if (view.IsDataRow(childHandle))
{
if (!childRows.Contains(childHandle))
childRows.Add(childHandle);
}
}
return childRows;
}
注意:我尚未測試代碼。 試試看。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.