I have a gridview with a bunch of groups in it. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.