I have this grid below. I have re-labeled the Bands and columns for sensistive data. I need to get a cell value and/or cell attributes. I have the UltraGridRow "gr" and UltraGridColumn "gc" coming into my method.
How do I get the cell?
Thanks,
Given that "gr" is your UltraGridRow object and "gc" is your UltraGridColumn object, the following code will give you a reference to the cell where the row and column meet:
using Infragistics.Win.UltraWinGrid;...UltraGridCell gcell = gr.Cells[gc];
You could instead pass in the Key of the desired UltraGridColumn object to the indexer of the Cells collection. Using the key is the most typical use case that I see. Since you already have the column in the scenario you've described, you may as well use it.
Thanks.
What if I did not have the gc and the gr? If I wanted to get the value in the "3X" column in the "2G" column of the first row?
To get the first row, you can use something like this:
UltraGridRow gr = ultraGrid1.Rows[0];
Once you have the row, you can get at the "3X" or "2G" cells in that row like this:
UltraGridCell gCell1 = gr.Cells["3X"];UltraGridCell gCell2 = gr.Cells["2G"];
I'm assuming, of course, that "3X' and "2G' are the keys for the relevant columns.
that should do it. Thanks for the help.
FYI - if you are interesting in the Value of the cell, as opposed to the cell object itself, you are better off using the GetCellValue method on the row to avoid unnecessarily creating UltraGridCell objects. Might save you some memory.
See the WinGrid Performance Guide for more details.