Can I get the UltraGridRow from and object that is in the list bound to the grid?
Say I have a list of employees bound to the grid, can I get the row if all I have available is the an employee object?
Thanks,
Glen
Hello Glen,
Have you been able to resolve your issue ? Did you have a time to try Mike`s suggestion. Please, if you have any questions, do not hesitate to ask me.
Regards
Hi Glen,
Yeah, when you group the grid the root level rows become GroupByRows.
What you could do in a case like that is loop through the data rows yourself and examine the ListObject property of each row to get the underlying DataRow from the data source and then compare.
To loop through all of the data rows, ignoring any grouping hierarchy, you can do something like this:
foreach (UltraGridRow row in this.ultraGrid1.Rows.GetAllNonGroupByRows()) { DataRow dataRow = ((DataRowView)row.ListObject).Row; if (dataRow == theRowIAmLookingFor) { MessageBox.Show("Fount it"); } }
Yes, I ran the example. It works fine except when the grid has group by columns. Then the UltraGrid.Rows collection is all "Group By" rows.
Did you have a time to take a look at the attached sample. Please if you have any questions, feel free to ask me
Maybe one possible approach to get UltraGridRow from your Employee object will be to use the code below:
UltraGridRow ugr;
ugr = ultraGrid1.Rows.Where(p => p.ListObject == Employee.emp).First();
If is it possible for you, please take a look at the attached sample. There are similar code which gets the UltraGridRow from UltraGrid based on the bound object.
Please if you have any questions, do not hesitate to ask me