TamarGranor said:
The key is to use something other than the base textbox class.
You can also program the text1 textbox that's put into every grid column. As always, there are pros and cons, and the best way is to preprogram a control you then use as grid column control, overriding the default native textbox, that's true.
Still, if you design a form, add a columncount just as many columns as the dbf or cursor you want to display at runtime has, then you can also put code in the textboxes that are created simply by setting a concrete columncount. Just like you can put a native control on a form, double click it and then program into that control on the form.
As you want this to work for every column that's already a case of DRY - dont repeat yourself - and creating a textbox class that reacts to the activation of it, most likely in the gotfocus event, which is exactly the event that always happens, no matter if you activate a control with mouse or tab to it. It gets the focus, and then this event happens, as it got the focus. There's even one that happens before the control gets focus and still the previous control has focus, the When event. So When or Gotfcus are the events you can pick for your concern.
So, indeed I second Tamars advice, create a control class for putting into grid columns.
Dronner said:
...it is just programming the event in each column.
Well, not if you'd literally wanted to program something in the column objects. They don't have any event of activation. It always is the control in the column that gets focus, not the whole column. When using DynamicCurrentControl that cna be one of many controls and always differing depending on which control is picked by the DynamicCurrentControl expression. Usually, though, just one control is the control of a column, repeatedly rendered for each row, there still is only one object, though. and only the current row has that object, so the text1 or however you name the control Tamar suggests you desing as class, will be the control of the active row, when events happen in it, you don't have 10 textboxes when your grid has 10 rows. And in that sense you also don't have to determine which is the rows control, it's only the rows current control, in which events happen, or even just the active cells control. So there is no need to know row or column number, the active cells control has events, you know what it's bound to, so you kjow the field, and you know the row in the dbf or cursor, as it's always just the current row of data.
Chriss