Hi,
could somebody please give me a possible use case for GetItemByName()? I suspect the function doesn't exactly do what it's supposed to do.
Markus
GetItemByName()
Started by Markus, Oct 06 2006 06:04 PM
7 replies to this topic
#1
Posted 06 October 2006 - 06:04 PM
It compiles, ship it!
#2
Posted 06 October 2006 - 07:58 PM
Hello,
This property return Item with specified name. Example:
I hope that this help,
Regards
This property return Item with specified name. Example:
CODE
NextInspector1.Items.ItemByName['testitem'].Caption := 'BorderWidth';
I hope that this help,
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 09 October 2006 - 10:39 AM
QUOTE (Boki (Berg) @ Oct 6 2006, 08:58 PM) <{POST_SNAPBACK}>
CODE
NextInspector1.Items.ItemByName['testitem'].Caption := 'BorderWidth';
Ok, I see. In this case the function works as expected.
Markus
It compiles, ship it!
#4
Posted 03 December 2006 - 08:30 PM
Hi Boki,
Is it an idea & possible to make this function case insensitive or would that break to much existing code?
Another request is to add a Name parameter to the AddChild call so you can compact code like:
and
QUOTE (Markus @ Oct 9 2006, 10:39 AM) <{POST_SNAPBACK}>
Ok, I see. In this case the function works as expected.
Markus
Markus
Is it an idea & possible to make this function case insensitive or would that break to much existing code?
Another request is to add a Name parameter to the AddChild call so you can compact code like:
CODE
NextInspector1.AddChild(TNxTextItem, 'Voornaam', 'VoornaamItem'). AsString := Klanten[ndx].Voornaam;
and
CODE
voornaam:=NextInspector1.Items.ItemByName['VoornaamItem'].AsString;
G.W. van der Vegt
#5
Posted 04 December 2006 - 03:23 PM
Hi Wim,
Why would you want to make this function case-insensitive? This property is very useful when dealing with items at runtime, i.e. creating and destroying them at runtime. Considering this use-case there's one problem: You can assign the same string to multiple name properties. Therefore I'm against making this function case-insensitive as this would allow more redundant name property choices.
Yeah, I'm in favor of this change. Just define AddChild as this
and you're still compatible with one's old code.
Cheers,
Markus
QUOTE (wvd_vegt @ Dec 3 2006, 08:30 PM) <{POST_SNAPBACK}>
Is it an idea & possible to make this function case insensitive or would that break to much existing code?
Why would you want to make this function case-insensitive? This property is very useful when dealing with items at runtime, i.e. creating and destroying them at runtime. Considering this use-case there's one problem: You can assign the same string to multiple name properties. Therefore I'm against making this function case-insensitive as this would allow more redundant name property choices.
QUOTE (wvd_vegt @ Dec 3 2006, 08:30 PM) <{POST_SNAPBACK}>
Another request is to add a Name parameter to the AddChild call so you can compact code like:
and
CODE
NextInspector1.AddChild(TNxTextItem, 'Voornaam', 'VoornaamItem'). AsString := Klanten[ndx].Voornaam;
and
CODE
voornaam:=NextInspector1.Items.ItemByName['VoornaamItem'].AsString;
Yeah, I'm in favor of this change. Just define AddChild as this
CODE
function AddChild(ItemClass: TNxItemClass; S: string = ''; Name: String = ''): TNxPropertyItem;
and you're still compatible with one's old code.
Cheers,
Markus
It compiles, ship it!
#6
Posted 04 December 2006 - 09:43 PM
Hi Markus,
Good point, BUT as you cannot have two objects shareing the same name, Delphi is case in-sensitive there (and the function works on the Name property of the item only as I discovered) it would not matter at all (or am I wrong here?). It would be different if the GetItemByName function where to act on the Caption property.
If it would be as you describe, I totally agree it's a bad move.
QUOTE (Markus @ Dec 4 2006, 03:23 PM) <{POST_SNAPBACK}>
Hi Wim,
Why would you want to make this function case-insensitive? This property is very useful when dealing with items at runtime, i.e. creating and destroying them at runtime. Considering this use-case there's one problem: You can assign the same string to multiple name properties. Therefore I'm against making this function case-insensitive as this would allow more redundant name property choices.
Markus
Why would you want to make this function case-insensitive? This property is very useful when dealing with items at runtime, i.e. creating and destroying them at runtime. Considering this use-case there's one problem: You can assign the same string to multiple name properties. Therefore I'm against making this function case-insensitive as this would allow more redundant name property choices.
Markus
Good point, BUT as you cannot have two objects shareing the same name, Delphi is case in-sensitive there (and the function works on the Name property of the item only as I discovered) it would not matter at all (or am I wrong here?). It would be different if the GetItemByName function where to act on the Caption property.
If it would be as you describe, I totally agree it's a bad move.
G.W. van der Vegt
#7
Posted 05 December 2006 - 12:26 PM
Hi Wim,
No, you're right. I was wrong in my assumption that you can assign the same name to multiple controls at run-time! Just tested that and it turned out that this results in an exception. Sorry for the fuss.
So, after all, I'm +1 on making the function case-insensitive.
Cheers,
Markus
QUOTE (wvd_vegt @ Dec 4 2006, 09:43 PM) <{POST_SNAPBACK}>
Delphi is case in-sensitive there (and the function works on the Name property of the item only as I discovered) it would not matter at all (or am I wrong here?).
No, you're right. I was wrong in my assumption that you can assign the same name to multiple controls at run-time! Just tested that and it turned out that this results in an exception. Sorry for the fuss.
So, after all, I'm +1 on making the function case-insensitive.
Cheers,
Markus
It compiles, ship it!
#8
Posted 05 December 2006 - 10:59 PM
Hi Markus,
Actually you can AS long as the controls reside on different forms. But that would automatically mean a different NextInspector too.
QUOTE (Markus @ Dec 5 2006, 12:26 PM) <{POST_SNAPBACK}>
Hi Wim,
No, you're right. I was wrong in my assumption that you can assign the same name to multiple controls at run-time! Just tested that and it turned out that this results in an exception. Sorry for the fuss.
So, after all, I'm +1 on making the function case-insensitive.
Markus
No, you're right. I was wrong in my assumption that you can assign the same name to multiple controls at run-time! Just tested that and it turned out that this results in an exception. Sorry for the fuss.
So, after all, I'm +1 on making the function case-insensitive.
Markus
Actually you can AS long as the controls reside on different forms. But that would automatically mean a different NextInspector too.
G.W. van der Vegt
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











