Hi,
I have a UltraWinGrid where with a numeric column that is toggable on/off. I have created an UltraNumericEditor and added the ultraNumericEditor to the form. I assigned the EditorControl property of the column to the UltraNumericEditor. The UltraNumericEditor has been configured with a StateEditorButton in the ButtonsLeft collection (to toggle on/off) and a SpinEditorButton in the ButtonsRight collection (to increment/decrement by a custom amount).
I would like the cells in this column to display the numeric value and the checkbox in the grid.
My problem is that when I check the StateEditorButton of one cell, all of the cells in the column receive the new CheckState. I have tried using the InitializeCheckState event of the UltraNumericEditor, but I have not been able to make it work correctly. It seems as though the Editor/EditorControl remembers the state of the last active cell (???).
I have also tried creating a different UltraNumericEditor for the specific cell in each row of the grid. When I do this, I get an exception if the up/down spin button is held down that the cell is not in edit mode.
Any thoughts/help would be greatly appreciated. Has anyone been able to get a check box and numeric editor working for cells of a column in the grid?
Thanks in advance!
Matt Snyder"] You might want to handle null/DBNull if the editor's value is currently blank, or if you allow nulls on that column. -Matt
You might want to handle null/DBNull if the editor's value is currently blank, or if you allow nulls on that column.
-Matt
Matt,
Yes, I do handle DBNull values. I just omitted them from the sample :).
Cheers,
Steve
Matt Snyder"] I just thought of a potentially better way of accomplishing this. Basically, when you change the Value of a cell, you're going to go through all the overhead associated with changing a cell's value (i.e. Before/After events, validation, etc). If you want to skip all of this and wait for all these events to fire until the user tries to leave the cell, you could manipulate the Editor's value instead, i.e.: try{ UltraGridCell gridCell = e.Context as UltraGridCell; if (gridCell != null) { EmbeddableEditorBase editor = gridCell.EditorResolved; int value = (int)editor.Value; editor.Value = value + 2; }}catch (Exception exception){ MessageBox.Show(exception.Message, "Grid Sample");} -Matt
I just thought of a potentially better way of accomplishing this. Basically, when you change the Value of a cell, you're going to go through all the overhead associated with changing a cell's value (i.e. Before/After events, validation, etc). If you want to skip all of this and wait for all these events to fire until the user tries to leave the cell, you could manipulate the Editor's value instead, i.e.:
try{ UltraGridCell gridCell = e.Context as UltraGridCell; if (gridCell != null) { EmbeddableEditorBase editor = gridCell.EditorResolved; int value = (int)editor.Value; editor.Value = value + 2; }}catch (Exception exception){ MessageBox.Show(exception.Message, "Grid Sample");}
Thank you very much. I replaced my 2 lines that set the value of the grid cell with the 3 lines of code you provided using the EmbeddableEditorBase, and I no longer get the exception when I hold the spin button down. Thanks!!!
I just created a simple sample with a single row in the grid, and the relevant column was of type int. I started the value at 1 and made sure that a different cell was in edit mode (just for testing a theory). I was able to hold down either of the spin buttons for a while and they worked correclty, so I suspect that something was fixed in a hotfix that is related to this issue. If you have already downloaded the latest hotfix and you still have this problem, as a workaround you could try what I mentioned in an earlier post about the PerformAction call, but you should still contact Developer Support so that you can be notified with the relevant fix is released.