Forum > Suggestions

Change in TreeView (treeview.inc)

(1/1)

jcmontherock:
Hello,
I suggest a little change in the function FindNodeWithText:
Change:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TTreeNodes.FindNodeWithText(const NodeText: string): TTreeNode;begin  Result := GetFirstNode;  while Assigned(Result) and (Result.Text <> NodeText) do    Result := Result.GetNext;end; 
To:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TTreeNodes.FindNodeWithText(StrtIndex: Integer = 0; const NodeText: string): TTreeNode;begin  Result := TreeView1.Items[StrtIndex];  while Assigned(Result) and (Result.Text <> NodeText) do    Result := Result.GetNext;end; 
If you have 2 (or more) nodes with the same text with a different parent node, you cannot find the next one.

wp:
Please post this in the bugtracker and mark it as feature request. The optional parameter must be at the end, though.

Martin_fr:
Also, since it returns a TTreeNode, maybe it should take a TTreeNode as optional arg?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TTreeNodes.FindNodeWithText(const NodeText: string; ContinueAfterNode: TTreeNode = nil): TTreeNode;
Just an idea.

Alextp:
Martin, +1.

jcmontherock:
Fine, it's more better...

Navigation

[0] Message Index

Go to full version