Jump to content


Photo

ColumnByName error


  • Please log in to reply
3 replies to this topic

#1 Burhan Cakmak

Burhan Cakmak
  • Members
  • 24 posts

Posted 07 July 2008 - 01:34 AM

Hi

I am using code

CODE

PRocedure Prop(Grd, Col, Prp, Val : String);
Begin
if Prp='Caption' then TNextGrid(FindComponent(Grd)).ColumnByName[Col].Header.Caption := Val else
if Prp='Width' then TNextGrid(FindComponent(Grd)).ColumnByName[Col].Width:=StrToInt(Val);
end;



It is code error ColumnByName




I using code
CODE

PRocedure Prop(Grd, Col, Prp, Val : String);
Begin
if Prp='Caption' then TNextGrid(FindComponent(Grd)).Columns[0].Header.Caption := Val else
if Prp='Width' then TNextGrid(FindComponent(Grd)).Columns[0].Width:=StrToInt(Val);
end;

It is code running



what promlem with ColumnByName ?


Thanks

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 07 July 2008 - 12:35 PM

Hello Burhan,

For me your code work fine. Please check if column name is passed correctly.

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 Burhan Cakmak

Burhan Cakmak
  • Members
  • 24 posts

Posted 20 July 2008 - 04:25 PM

Hi Boki

I using code runtime

CODE

....
procedure TForm1.Button1Click(Sender: TObject);
var
NextGrid1: TNextGrid;
begin
// Grid Created
NextGrid1 := TNextGrid.Create(Self);
with NextGrid1 do
begin
Name := 'NextGrid1';
Parent := Self;
Left := 488;
Top := 284;
Width := 250;
Height := 150;
TabOrder := 0;
TabStop := True;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
// Column Created
TNextGrid(FindComponent('NextGrid1')).Columns.Add(TNxTextColumn, 'Osman');
TNextGrid(FindComponent('NextGrid1')).ColumnByName['Osman'].Header.Caption:='Deneme';
TNextGrid(FindComponent('NextGrid1')).ColumnByName['Osman'].Width:=150;
// Column by name error....
end;
....


What problem with ColumnByName method,

Thanks

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 20 July 2008 - 04:43 PM

Hello Burhan,

You need to set Name property of column:

CODE
procedure TForm1.Button2Click(Sender: TObject);
begin
// Column Created
TNextGrid(FindComponent('NextGrid1')).Columns.Add(TNxTextColumn, 'Osman').Name := 'Osman';
TNextGrid(FindComponent('NextGrid1')).ColumnByName['Osman'].Header.Caption:='Deneme';
TNextGrid(FindComponent('NextGrid1')).ColumnByName['Osman'].Width:=150;
// Column by name error...
end;


In your example when using Columns.Add you are setting Caption property to 'Osman'

I hope that now helps.

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users