Jump to content


Photo

Find column from its header caption?


  • Please log in to reply
2 replies to this topic

#1 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 06 October 2009 - 02:23 PM

Hello

I may have overlooked it, but I didn't find if it's possible to retrieve a column by its header caption? I'd like to do this in order to set the column's Name property without hard-coding the column index:

CODE
With NextGrid1 do begin
  //2nd param is caption, not name
  Columns.Add(TNxTextColumn,'Value');
  //GPF
  Columns.Column['Value'].Name := 'value';
end;


Thank you.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 06 October 2009 - 05:51 PM

Hello Fred,

You will need to manually set Header.Caption to desired value and then with using loop find a column with this Header.Caption.

Something like:

CODE
for i := 0 to NextGrid1.Columns.Count -1 do
begin
  if NextGrid1.Columns[i].Header.Caption = s then
  begin
    ShowMessage('Find!');
    Exit;
  end;
end;


Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 06 October 2009 - 06:17 PM

Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users