Hi,
I have an UltraWinGrid that contains 4 columns, with column 1 set as Activation.AllowEdit and columns 2-4 set as Activation.Disabled in the InitializeLayout event.
Upon the user entering a value into column 1, I need to either keep columns 2-4 disabled or enable them, depening on the value that was entered.I have tried assessing this value in several events (InitializeRow, BeforeRowUpdate, AfterCellUpdate, AfterRowUpdate) and setting the Activation to Activation.AllowEdit, but the behaviour when enabling columns 2-4 is not quite as I would want it, in that pressing tab after entering the value in column 1, does indeed enable columns 2-4, but rather than moving to column 2 for entry, it updates the row, meaning the user has to navigate back to the newly activated column 2.
Is there anything you can think of that would allow the enabling of a column and move to this column, rather than update the row?
The problem is that - when you press the Tab key, the grid is calculating all of the actions it has to take to handle that key. Then it starts processing those actions, and all of the events you listed here are fired in response to some action. So by the time the event fires, the grid has already determined that it should skip over the disabled cells and tab to the next available cell, which is the column 1 cell in the next row.
So you have a couple of options here.
One way to handle this is to use an event that fires before the grid processes the Tab key. This means you would have to update the Activation of the cells on every keystroke. You could use the CellChange event for this. There are a couple of issues you will need to deal with if you take this approach. First, the Value property on the cell will not be update when CellChange fires. You would have to use the cell's Text property instead. Depending on the DataType of the field, this could be a problem, since the Text might not be valid. If the field is a Date, for example, the user might be in the process of entering it, and it may not be complete.
Another approach would be to use the TabStop property on the column. I think the grid probably skips the disabled columns by default, but setting TabStop explicitly to true might allow the user to tab into those disabled columns. I may be wrong. This might not work for dsiabled. But I am pretty sure it will work for Activation.NoEdit and/or Activation.ActivateOnly. These settings do not allow the user to edit the fields, but still let them select them. The down side of this approach is that the user will have to tab through three extra columns when they are not editable.
Hi Mike,
Thanks for your reply.
I went with your first suggestion, but just a note to other people trying to do the same thing. If you set the Activation of the cells to anything other than AllowEdit in the InitializeLayout, the cell carries that state throughout.
What I did was to set the columns to Disabled in the InitializeRowLayout and then use the CellChange event (as suggested) to control the Activation states. Works a treat.
Oh, good point. If you set the CellActivation on the column and then you want to override it on a single cell, you have to set IgnoreRowColActivation on the cell to true, in addition to setting the cell's Activation.
Or you can just not set CellActivation on the column.