In an UltraGridRow, if you programmatically assign something to cell.text (i.e. MyRow.cells(0).text = "ABC"), when will the corresponding cell.value (MyRow.cells(0).value) get updated to have the "ABC" value?
Ron,
I am curious what prompted the question, is there something not working as you expect in the grid? If so we may be able to provide some guidance if you describe what it is that you are seeing.
Just to answer your original question, the Text is 'committed' to the cell based on the UpdateMode property. By default, this will happen when the user leaves the cell (activates some other cells in the grid) or the grid loses focus.
If you want to fully understand the difference between Text and Value, it's helpful to imagine an example of cell in the grid that contains a DateTime value. Suppose the user clicks into edit mode on such a cell and they intend to type "12/25/2018". As soon as they type a single character "1", the Text of the cell has changed. Text, in this context represents the actual text the user sees on the screen. But the Value has not changed. the Value CANNOT change in this example, because "1" is not a valid date. So changing the Value in this instance would be bad. The only thing the grid could do would be to set the Value to null, which would mean losing the original value and the user would then be unable to undo the change.
So Text is what you see on the screen. Value is the underlying value in the data source - which only gets updated when the user "commits" the change. And the grid only knows when the user is 'done' when they leave the cell or lose focus on the grid. You can change this behavior with the UpdateMode property if you really wanted to. But the default works well in almost all cases.
Hi Alan, no I don't have an example. I was just asking to get a fuller understanding of the interaction between cell.text and cell.value. Your response helped with my understanding of this. Thanks so much.
I wouldn't expect code setting the Text property of an UltraGridCell to compile as there is no setter for the property. I even checked the code as far back as 2008 and there wasn't a setter then.
Looking at the code, if the cell is in edit mode the Text property of the cell returns the text from the editor and if it isn't in edit mode it returns the value that the GetCellText method of the Column returns.
Do you have an example where setting the Text on an UltraGridCell does work?
HI Mike, Thanks for your response. I know that the cell.text is the formatted text version of what is in cell.value, however, I'm curious as to what would happen if you programmatically assigned cell.text. Would it ever propagate to cell.value? If so, how and when?