What are the possible ways to get the cell values?
Here is some background:
I have a grid with 2 visible column. Basically like a property grid, Labels on the left and vaues on the right.
Each row is an item in what will become a filter. What I am looking to do is get all the values of the cells.
I have attempted to do this in the Validating event but have been unable to get to the needed data...
Any ideas??
Do you need to loop through all of the rows in the grid? It's hard to suggest exactly which approach is best without knowing how you want to use it, but there is a Value property on a cell, or the GetCellValue property on the Row (which has the benefit of not forcing the cell to be created if it isn't already). If you need to loop through all the rows in the grid, and your grid isn't hierarchical, you could do something like:
foreach (UltraGridRow row in this.ultraGrid1.Rows){ foreach (UltraGridColumn col in this.ultraGrid1.DisplayLayout.Bands[0].Columns) { object cellValue = row.GetCellValue(col); // Do things with cell value }}
-Matt
In some instances the grid will be grouped. So yes it can be hierarchial.
I got around this by first clearing the sortedcolumns collection:
with grdFilters if .HasChildren then grdFilters.DisplayLayout.Bands(0).SortedColumns.Clear end if
As for the cell values I need to get specific columns. Is there anyway to set a KEY on the cells?
Hi
>>As for the cell values I need to get specific columns. Is there anyway to set a KEY on the cells?
Use cell.Column.Key for that.
Alex