By Charles R Hankey - 9/17/2010
I have an ultrawingrid in a groupbox. If I am in a dirty cell, then click save, the changes to the current dirty cell are not saved. As best I can tell this is because the buttons on the toolstrip do not actually get focus, so the lostfocus of the cell, grid, groupbox do not fire.
If I just put a button on the form and put Me.Save() in the click all is well and the dirty cell saves as shown.
So, I found the itemclicked event of the toolstrip and I can determine which button was clicked but setting focus to that button doesn't seem to be an option.
Is there an elegant way to fire a focus() if the choice is Save so that the cell will save properly? or should I just put my own save button over the save button on the toolbar (seems to come as a set with Undo) and then handle the enabling etc myself. ?
TIA
Charles
|
By Charles R Hankey - 9/17/2010
Charles, once again a particularly well explained and insightful question
It seems setting focus to the toolstrip itself is the trick
This is now in the MaintenanceformToolStrip_itemClicked() event
If e.ClickedItem.Name = "cmdSave" then Me.MaintenanceFormToolStrip1.Focus() End If
and now it seems happy. If I click Save directly from a dirty cell the changes shown in the cell are retained.
( now when I forget how this works I can Search on the forum )
|
By Randy Jean - 9/18/2010
LOL, this from the guy who teased me about talking to myself on the F1 forums.
I was going to say you could always subclass your form and create a writebuffer method that the save calls
|
By Charles R Hankey - 9/18/2010
Thought you might get a kick out of that.
I was looking for something *really* simple. Remembered that it was often necessary to not have a control get focus so you could escape from some field that wouldn't validate. Still don't know how they keep a maintenance strip from getting focus by default and was frankly a bit surprised to see that calling it explicitly works but so far seems to be the answer. ( and I really trust the guy who answered it ... )
|
By Ivan George Borges - 9/20/2010
That was great, Charles.
I do have a small invisible textbox on my base form that I always make visible, set focus and make invisible in its BeforeSave method. That did the trick for me for all my forms.
|