[英]How can I find the last row of a group in a DevExpress gridview?
I have a gridview with a bunch of groups in it. 我有一个gridview,里面有很多组。 I also have up/down buttons which move the datarows inside of the groups up/down.
我还具有向上/向下按钮,可以向上/向下移动组内的数据行。 If the datarow is the last row in the group, I don't want the row to do anything when the user presses the "down" button.
如果数据行是组中的最后一行,那么当用户按下“向下”按钮时,我不希望该行执行任何操作。 How can I check to see if the data row is the last row in the group?
如何查看数据行是否为组中的最后一行?
You can try this 你可以试试这个
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;
}
Note: I haven't tested the code. 注意:我尚未测试代码。 try it out.
试试看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.