There seems to be a bug with the Insert method of TNextGrid.
Insert(TNxTextColumn, 1) does the following:
Creates the column
Sets the parent component to itself (Which adds it to the Columns collection)
Calls InsertColumn which also adds it to the columns collection.
The column gets added twice which results in the column count being 1 more than actually exists and therefore an Index Out of Bounds error occurs.
The only way to insert a column without this error that I can see is to create the column yourself and then call InsertColumn instead.
NextGrid Insert Bug
Started by Biblin, Oct 18 2006 11:59 AM
7 replies to this topic
#1
Posted 18 October 2006 - 11:59 AM
#2
Posted 18 October 2006 - 12:44 PM
Hello,
You are correct. I will fix it now. Thank you.
regards
You are correct. I will fix it now. Thank you.
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.
--
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
Posted 18 October 2006 - 02:16 PM
Cheers, now that's service 
Second bug while you're at it. Insert doesn't actually seem to insert, it just adds.
Checking through the code it looks like you insert the item into the correct position in FItemList and add it to the end of FPositionItemsList which is the list actually used for positioning. Shouldn't it be the other way around?
Second bug while you're at it. Insert doesn't actually seem to insert, it just adds.
Checking through the code it looks like you insert the item into the correct position in FItemList and add it to the end of FPositionItemsList which is the list actually used for positioning. Shouldn't it be the other way around?
#4
Posted 18 October 2006 - 05:14 PM
Hello Biblin,
Comment line where it stay: SetParentControl(). This line is not needed.
regards
Comment line where it stay: SetParentControl(). This line is not needed.
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.
--
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.
#5
Posted 18 October 2006 - 06:26 PM
QUOTE (Boki (Berg) @ Oct 18 2006, 05:14 PM) <{POST_SNAPBACK}>
Hello Biblin,
Comment line where it stay: SetParentControl(). This line is not needed.
regards
Comment line where it stay: SetParentControl(). This line is not needed.
regards
It should be SetParentComponent., and what about Biblin's second bug report?
William
#6
Posted 18 October 2006 - 06:46 PM
Hello,
Here is complete procedure:
Please note that after inserting column you need to se Position for column (!)
regards
Here is complete procedure:
CODE
function TNxColumns.Insert(ColumnClass: TNxColumnClass; Pos: Integer): TNxCustomColumn;
begin
Result := ColumnClass.Create(Self);
Result.FColumns := Self;
with Owner as TNxCustomGrid do
begin
Result.Color := Color;
Result.Cursor := Cursor;
Result.Font.Assign(Font);
end;
InsertColumn(Result, Pos);
end;
begin
Result := ColumnClass.Create(Self);
Result.FColumns := Self;
with Owner as TNxCustomGrid do
begin
Result.Color := Color;
Result.Cursor := Cursor;
Result.Font.Assign(Font);
end;
InsertColumn(Result, Pos);
end;
Please note that after inserting column you need to se Position for column (!)
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.
--
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.
#7
Posted 18 October 2006 - 07:03 PM
QUOTE (Boki (Berg) @ Oct 18 2006, 06:46 PM) <{POST_SNAPBACK}>
Hello,
Please note that after inserting column you need to se Position for column (!)
regards
Please note that after inserting column you need to se Position for column (!)
regards
Hi, Boki
Thanks. but why don't set the position inside the Insert procedure itself?
William
#8
Posted 18 October 2006 - 08:03 PM
Hello William,
I will think about it. Until then, you may use next code
NextGrid1.Columns.Insert(TNxTextColumn, 4).Position := 4;
regards
I will think about it. Until then, you may use next code
NextGrid1.Columns.Insert(TNxTextColumn, 4).Position := 4;
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.
--
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











