 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Martyn Davies Guest
|
Posted: Fri Apr 16, 2004 2:23 am Post subject: TDBGridColumns Problem |
|
|
Hi
Does anyone know of a way of finding out if a field is
currently being displayed in a TDBGrid without iterating
through the columns?
Is there some way TDBGridColumns as a collection can be
used for his purpose, perhaps - something like FindItemId,
maybe?
Using D5pro, XP, MSAccess97
Any help greatly appreciated.
Regards
Martyn Davies
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Fri Apr 16, 2004 3:46 am Post subject: Re: TDBGridColumns Problem |
|
|
A quick check of the methods of TDBGridColumns in the on-line help
shows no such method. :)
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Martyn Davies Guest
|
Posted: Fri Apr 16, 2004 4:45 am Post subject: Re: TDBGridColumns Problem |
|
|
| Quote: | A quick check of the methods of TDBGridColumns in the on-line help
shows no such method.
|
Hi Bill
Thanks for your response.
According to the help on TCollection, FindItemId is one
of its methods. If TDBGridColumns is descended from
TCollection, shouldn't I be able to reference TColumn items as
TCollection items and find out if the field I'm looking for
is in the collection?
Something along the lines of:
....
var
i: Integer;
TCollection(dgProduct.Columns).FindItemId(MyColumnIndex)
....
Trouble is, I know the FieldName but not its ColumnIndex.
Regards
Martyn Davies
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Fri Apr 16, 2004 8:33 am Post subject: Re: TDBGridColumns Problem |
|
|
The TDBGrid have the SelectedField property where you may get the current
selected field
--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com
"Martyn Davies" <martyncd (AT) ctrlx (DOT) hotmail.com> wrote
| Quote: |
Hi
Does anyone know of a way of finding out if a field is
currently being displayed in a TDBGrid without iterating
through the columns?
Is there some way TDBGridColumns as a collection can be
used for his purpose, perhaps - something like FindItemId,
maybe?
Using D5pro, XP, MSAccess97
Any help greatly appreciated.
Regards
Martyn Davies
|
|
|
| Back to top |
|
 |
Martyn Davies Guest
|
Posted: Fri Apr 16, 2004 1:21 pm Post subject: Re: TDBGridColumns Problem |
|
|
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote:
| Quote: | The TDBGrid have the SelectedField property where you may get the current
selected field
Thanks for your input, Mike |
However, let me clarify...
I have a grid which may show any number and any combination
of fields from a dataset of 43 fields. I need to find out if
any one of the 43 fields is currently being displayed in the
grid.
Regards
Martyn Davies
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Fri Apr 16, 2004 1:29 pm Post subject: Re: TDBGridColumns Problem |
|
|
On 15 Apr 2004 21:45:08 -0700, "Martyn Davies"
<martyncd (AT) ctrlx (DOT) hotmail.com> wrote:
| Quote: | Trouble is, I know the FieldName but not its ColumnIndex.
|
Exactly. That was obvious from your original message and there is no
way to search the collection by field name. You will have to write
your own method to loop through the columns collection to find the
name you want.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Quasidata Guest
|
Posted: Sun Apr 18, 2004 6:01 am Post subject: Re: TDBGridColumns Problem |
|
|
Hello Martyn,
Here is a sample.
procedure TForm1.Button1Click(Sender: TObject);
const
MyFieldName = '';
var
MyColumn: TColumn;
begin
MyColumn := MyFindColumn(MyFieldName);
if Assigned(MyColumn) then
Caption := IntToStr(MyColumn.Index);
end;
function TForm1.MyFindColumn(const AFieldName: string): TColumn;
var
MyColumns: TDBGridColumns;
I: Integer;
begin
MyColumns := DBGrid1.Columns;
for I := 0 to MyColumns.Count - 1 do begin
Result := TColumn(MyColumns[I]);
if AnsiCompareText(Result.FieldName, AFieldName) = 0 then Exit;
end;
Result := nil;
end;
--
Andrei Fomine www.quasidata.com
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@Once - full-blown clipboard and drag-and-drop data transfer to/from
any control in many formats, including ones native to MS Office.
"Martyn Davies" <martyncd (AT) ctrlx (DOT) hotmail.com> wrote
| Quote: |
Hi
Does anyone know of a way of finding out if a field is
currently being displayed in a TDBGrid without iterating
through the columns?
Is there some way TDBGridColumns as a collection can be
used for his purpose, perhaps - something like FindItemId,
maybe?
Using D5pro, XP, MSAccess97
Any help greatly appreciated.
Regards
Martyn Davies
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|