I am selecting the column in a data grid to gather each cells data in that particular column and send each cells value through a some regex to validate it.
Example code
For each strLine as String in (ultragridname).Selected.columns.all
next
It blows up at the "All" stating that the header cna't be changed to a string. I don't need the header, how do I get the header out of the list? or at least work around it?
Hi,
The Selected.Columns collection contains a collection of column headers representing the selected columns. It's not a string, it's instance of a ColumnHeader class. From the ColumnHeader, you could get the Column property to get the actual UltraGridColumn object. And from the column you could get the Key to index into the cells of a row. Although you really don't need the key, since the Cells collection indexer will take a column.
If you are trying to loop through all of the cells in the selected columns, then you would have to do something like this:
foreach (UltraGridRow row in grid.Rows) { foreach (Infragistics.Win.UltraWinGrid.ColumnHeader columnHeader in grid.Selected.Columns) { UltraGridColumn column = columnHeader.Column; // Examine the cell value here Debug.WriteLine(row.Cells[column].Value); } }