I have a cell (“process_order”) that is inactive w/no tab stop until the user makes a selection in another column (“selected”) on the row; once the user clicks the “selected” cell, I would like to activate the “process_order” cell and have the “process_order” cell become the active cell.
I have the code working to enable/activate the cell but the process always jumps to the next cell (“email”) in the row instead of the newly the “process_order” cell – any ideas? Thanks
if (this.grdResults.ActiveRow != null && (bool)this.grdResults.ActiveRow.Cells["selected"].Value )
{
this.grdResults.ActiveRow.Cells["process_order"].IgnoreRowColActivation = true; //just in case…
this.grdResults.ActiveRow.Cells["process_order"].TabStop = Infragistics.Win.DefaultableBoolean.True; //ensure the user can actually stop there
this.grdResults.ActiveRow.Cells["process_order"].Activation = Activation.AllowEdit; //allow editing of the cell
this.grdResults.PerformAction(UltraGridAction.EnterEditMode, false, false); // what the heck this might help too
this.grdResults.ActiveRow.Cells["process_order"].Selected = true; // thinking this should really do the trick - nope
this.grdResults.ActiveCell = this.grdResults.ActiveRow.Cells["process_order"]; // if not this one should –right?
}
I have tried this and variations of this in the following events:
BeforeCellDeactivate, AfterCellUpdate, BeforeExitEditMode
Okay, if selected is a checkbox that makes things a lot easier. In that case, I would use the CellChange event. That way tab or click doesn't matter because you will be changing the focus BEFORE the user even tries to leave the cell.
My guess is that the problem you were having before is that your code was triggering while the grid was in the middle of processing the tab key. So you set focus to the next cell and then grid processes the tab and so you end up one cell too far. Using CellChange will fix that, as well, unless the user clicks the checkbox and then presses tab when they are already in the correct cell. :)
The one caveat is that the cell's Value will not be updated when CellChange fires. So in order to determine if selected it true inside the CellChange event, you have to use the cell's Text property, instead. You can either examine the text for "true" or do a bool.Parse on the text to get the boolean value. I would probably go with the latter.
Thanks - yes, the SELECTED field/cell is a check box and I would like to enable and activate the PROCESS ORDER cell/field once the SELECTED = true...
I have the PROCESS ORDER column disabled and once the user selects the vendor I would like the PROCESS ORDER field to be enabled and activated ... I have tried many of the things I found but could not get things to work properly. Hence my posting...
So, I thought I needed to enable the cell, and then set the cell to active; I could get the cell enabled but the focus always went to the field after the PROCESS ORDER:
this.grdResults.ActiveCell = this.grdResults.ActiveRow.Cells["process_order"];
Actually, once they user has clicked on the SELCTED cell (and set it too true) I would like to enable the PRCOESS ORDER field - regardless if they TAB or CLCIK - is this possible? Thanks again!
Hi,
rexmac1 said:this.grdResults.ActiveRow.Cells["process_order"].Selected = true; // thinking this should really do the trick - nope
No, this will do nothing to change the focus.
rexmac1 said: this.grdResults.ActiveCell = this.grdResults.ActiveRow.Cells["process_order"]; // if not this one should –right?
Yes, this is correct.
The code you have here doesn't make a lot of sense to me, though. At least not if you are using BeforeCellDeactivate or BeforeExitEditMode. AfterCellUpdate might make sense in some cases, but you seem to be making a really big assumption here which is that the user tabbed out of the cell.
I'm assuming that the "selected" column is immediately before the "process_order" column and you want to handle the case where the user changes "selected" to true and then tabs to the next cell. Is that right? Or is the "selected" cell a checkbox and you want to set the focus as soon as they check it?
If it's not a checkbox, then what happens if the user sets "selected" to true and the clicks on some other cell directly? You want to force them back into the "process_order" cell?
Assuming I am correct about all this, then I think your best bet would be to use the BeforePerformAction event so you can trap for the tabbing from one cell to another. That way the code would be limited to tabbing and would not fire if the user clicked on a specific cell.