Excuse me if I'm using the incorrect terms as this Infragistics stuff is new to me.
The Groups are declared as GroupID, and the Users are declared as UserID. The bold portion of the code works, but only for the first group. It's grabbing a value from a textbox (popup) and comparing it to what I have on the grid.
I think it's best illustrated here:
Group 1
Group 2
I've done it manually so far:
GridRowType rowTypes = GridRowType.DataRow;UltraGridBand band = frm.ultraGridUsers.DisplayLayout.Bands[1];IEnumerable enumerator = band.GetRowEnumerator(rowTypes);foreach (UltraGridRow row in enumerator){if ((ultraTextEditorUnit.Text == row.Cells["UnitID"].Text) && (ultraTextEditorGroupAlias.Text == frm.ultraGridUsers.DisplayLayout.Rows[0].Cells["Alias"].Text)) { MessageBox.Show(this, "Duplicate UnitID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.ultraTextEditorUnit.Focus(); allowClose = false; } else allowClose = true; }
Hi,
It looks like what you have here is a grid bound to a hierarchical data source. You are probably binding the grid to a DataSet with two tables and a Relationship defined between the two. The term 'band' refers to a particular level in the hierarchy of the data. So you have two bands.
If you have access to the grid row that you are validating, then getting the collection of rows to which that row belongs is very simple.
foreach (UltraGridRow siblingRow in row.ParentCollection) { if (row == siblingRow) continue; // Validate here }
foreach (UltraGridRow siblingRow in row.ParentCollection)
{
if (row == siblingRow)
continue;
// Validate here
}
Mike Saltzman said:It's hard to tell from this screen shot, but it does not appear to me that you are using any grouping functionality in this grid. It looks like you just have 2 bands
Do I have to set something in the Designer Dialog in order to enable this?
Mike Saltzman said:Are you trying to validate all of the child rows in the entire grid? Or just one set of child rows to which the new row you just added belongs?
One set of child rows, not the entire grid.
Mike Saltzman said:So basically, all you have to do here is loop through the child rows collection under each parent row.
How do I do this without the Enumerator? Is it possible to do it with a foreach for each parent? I think the bands[0] takes the top-most parent.
Again, I apologize as I'm not familiar with the terminology of the "bands" and what not.
Thank you.
It's hard to tell from this screen shot, but it does not appear to me that you are using any grouping functionality in this grid. It looks like you just have 2 bands - which explains why your original code doesn't blow up when you try to access the cells collection of the first row.
So basically, all you have to do here is loop through the child rows collection under each parent row.
Are you trying to validate all of the child rows in the entire grid? Or just one set of child rows to which the new row you just added belongs?
By using the GetRowsEnumerator like you are doing, you are looping through every child row in the whole grid. But that doesn't really make sense, since it's okay to have the same value in the child row as long as it's under a different parent row.
hi Mike,
Thanks for your reply. I highly doubt I'm using the correct terminology when it comes to these tools as they are new to me and I've never used them before. I've attached an image as reference:
The end-users of the software can enter a 'User #' through a form. They can also create 'Groups.' I guess my confusion was that the Groups (parents) were called Bands and each child was a Row.
Here's the problem: An end-user can only add one unique User I.D. to one group (parent). User I.D.s are (User 1, User 2, User 3). An error should be thrown when there are multiple rows with the same User I.D. within a group (marked by an asterisk in Group 2 - "Bravo")
I'm having a hard time understanding the situation and what you are trying to do.
What do you mean by Groups? Are you using OutlookGroupBy to group the grid? When you are using OutlookGroupBy to group the grid by a particular column, the root-level rows in the grid become the GroupByRows and the second level rows are the actual data rows.
So it looks like you are trying to ensure that a user does not show up more than once within the same GroupByRow.
So you are using the GetEnumerator method to loop through all of the rows in Band 1. Band 1 is a child band, though.. does your grid have more than one band? There does not appear to be any mention of a second band here.
Either way, the code you here doesn't make much sense. In particular, this part:
frm.ultraGridUsers.DisplayLayout.Rows[0]
Rows[0] will return the first row at the root level of the grid, which in this case is the root band's first row, which is a GroupByRow - it's the "Group 1" row. This row does not have any cells, so this code should be blowing up immediately.