Subject | [IBO] Re: Moving column in a grid |
---|---|
Author | Ryan Nilsson-Harding |
Post date | 2002-11-13T00:11:11Z |
Thanks for the suggestion Helen,
but the .SelectedField property is a read-only property so I can't
assign it any value. This was actually what I tried first.
Also, I have taken out the
...AsString := 'SAMPLE';
line of code, so that the only line is the
...('QTY').FocusControl;
but even that does not work, so I'm assuming it doesn't have
anything to do with the first line assigning data to the DESCR field.
I'm a little stumped with this.
Could it be that when .FocusControl is assigned, it is merely
focusing on the grid, instead of the column?
rgds,
-Ryan
but the .SelectedField property is a read-only property so I can't
assign it any value. This was actually what I tried first.
Also, I have taken out the
...AsString := 'SAMPLE';
line of code, so that the only line is the
...('QTY').FocusControl;
but even that does not work, so I'm assuming it doesn't have
anything to do with the first line assigning data to the DESCR field.
I'm a little stumped with this.
Could it be that when .FocusControl is assigned, it is merely
focusing on the grid, instead of the column?
rgds,
-Ryan
>guess
> >That said, I've tried your suggestion but it still does not go to
> >the field I'm trying to select.
> >What I'm doing is setting a value in another field, then trying to
> >move the focus to the next field:
> >
> >if not qryOrder.FieldByName('STOCK_ID').IsNull then begin
> > qryOrder.FieldByName('Desc').AsString := 'SAMPLE';
> > qryOrder.FieldByName('Qty').FocusControl;
> >end
> >else
> > raise Exception.Create('Must have a stock item!');
> >
> >I have stepped through this code, and the .FocusControl proc is
> >definately being called, but nothing seems to happen.
> >The focus remains on the 'Desc' field.
>
> FocusControl theoretically should work and, because it isn't, I'd
> that either a) the SelectedField property (still on 'Desc') isoverruling
> it or b) at the time you call FocusControl, the ib_datasourcehasn't yet
> updated the dataset and so FocusControl isn't finding theconditions you
> think it ought to.try and
>
> Try assigning the SelectedField property of the grid *first*, to
> force the focus off the Desc field. That should cause the datasetto get
> updated, so SelectedField might do the job for you alone. If not,keep the
> FocusControl there as well, but following the Grid.SelectedFieldcall.
>
> So we'd have now:
>
> if not qryOrder.FieldByName('STOCK_ID').IsNull then begin
> qryOrder.FieldByName('Desc').AsString := 'SAMPLE';
> MyGrid.SelectedField := qryOrder.FieldByName('Desc');
> // qryOrder.FieldByName('Qty').FocusControl;
> end
> else
> raise Exception.Create('Must have a stock item!');
>
> Helen