|
|
Question : "Grid Index out of range" errors at different screen resolutions
|
|
This problem only seems to occur at low screen resolutions. A query produces a dataset which is to be displayed in a TDBGrid. The dataset is scanned to find the largest width field and this figure is used to set the column width for that field:
dsKey->DataSet = qKey; // The TDataSource qKey->Open(); // a TQuery
while(!qKey->Eof){ Max = (Max < Canvas->TextWidth(qKey->Fields-Fields[0]->AsString)) ? Canvas->TextWidth(qKey->Fields->Fields[0]->AsString) : Max; qKey->Next(); } dbgKey->Columns->Items[0]->Width = Max + 10;// Max is usually around 200
Ths last statement produces an EInvalidGridOperation error: "Grid index out of range", but only at lower screen resolutions. Interestingly, if this statement is repeated in a 'Catch' envelope, it is accepted.
Anyone see the flaw?
|
Answer : "Grid Index out of range" errors at different screen resolutions
|
|
Per recommendation, points NOT refunded and question closed.
Netminder CS Moderator
|
|
|
|
|