Possible BUG in Pages collection!

Topics related to the Krypton Navigator.

Moderators: Phil Wright, Chris Porter

Possible BUG in Pages collection!

Postby figuerres » Wed Sep 20, 2006 6:42 am

Code: Select all
For Each P As KryptonPage In Me.MainNavigator.Pages
  Console.WriteLine("Page.Name=" & P.Name & "  Page.Visible=" & P.Visible)
Next

If user.IsInRole(Roles.Cashier.ToString()) Then
  Me.MainNavigator.Pages("Sales").Visible = True
Else
  Me.MainNavigator.Pages(0).Visible = False
End If


refering to the page "By Name" throws a null exeption.
but "By Index" works
Page 0 is named "Sales"

Seems like a bug to me....
figuerres
 
Posts: 38
Joined: Sun Jul 30, 2006 10:25 am

Postby figuerres » Wed Sep 20, 2006 12:09 pm

If I am right then:

Code: Select all
                foreach (KryptonPage page in this)
                    if (page.UniqueName == uniqueName)
                        return page;


is the if ( x==y) doing a reference compare ?
when what we need is a Value compare ....

if I have time I may try to tweak and compile that and see what happens.
figuerres
 
Posts: 38
Joined: Sun Jul 30, 2006 10:25 am

Postby Phil Wright » Wed Sep 20, 2006 5:44 pm

Hi

When you use KryptonNavigator.Pages["xyz"] to recover a page use the collection indexer it will perform a search using "xyz" against the UniqueName property of each page to try and find a match.

The idea of the KryptonPage.UniqueName property is that it will never be displayed to the user, unlike the Text, TextTitle and TextDescription properties. Therefore you can assign a name to UniqueName and then look it up using the collection indexer. Where as you might have different Text strings depending on the locale and so you cannot reliably look up using the Text set of properties.

Hope that helps[/b]
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Postby figuerres » Thu Sep 21, 2006 5:46 am

Phil Wright wrote:Hi

When you use KryptonNavigator.Pages["xyz"] to recover a page use the collection indexer it will perform a search using "xyz" against the UniqueName property of each page to try and find a match.

The idea of the KryptonPage.UniqueName property is that it will never be displayed to the user, unlike the Text, TextTitle and TextDescription properties. Therefore you can assign a name to UniqueName and then look it up using the collection indexer. Where as you might have different Text strings depending on the locale and so you cannot reliably look up using the Text set of properties.

Hope that helps[/b]


Ahhhhh...... I was thinking like the winform tab control
where .Name is the key to the collection.

Now I get it.
figuerres
 
Posts: 38
Joined: Sun Jul 30, 2006 10:25 am

Pages collection bug

Postby linusaurus » Wed Oct 04, 2006 12:58 am

i also have the problem with refering to a page using a string where the index otherwise works fine
linusaurus
 
Posts: 5
Joined: Wed Oct 04, 2006 12:56 am
Location: San Diego, California

Postby Phil Wright » Wed Oct 04, 2006 10:42 am

Remember that the string using as the index is matched against KryptonPage.UniqueName. Check that you are using the same name as the UniqueName property.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

idea for page names

Postby figuerres » Sat Oct 07, 2006 2:40 am

Phil,

I think your "UniqueName" idea is interesting but might be overkill in many cases.

an idea to help out some folks:

have an option "MS Tab Mode" or "SimpleName Mode"

where the Page.Name value and the Page.UniqueName and the .Text are all related and the Name and UniqeName can be made uniqe when needed.

so for example if the dev sets the .Text to say "Merchant Settings"
then .Name and .UniqueName get set to "MerchantSettings" unless the pages collection would have a name conflict.
then do one of the following:
warn the developer
append a value like "MerchantSettings2" to the .Name and .UniqueName
or append a Unique value kind of like you do as in "MerchantSettings_AB1F" for example.

so far I find that in my app I am spending time making each page have the .Name and .UniqueName be the same. I really do not see a value to having a random name as the string index.

and as far as I can recall other collections just use a .Name as the string index.
figuerres
 
Posts: 38
Joined: Sun Jul 30, 2006 10:25 am

Postby Phil Wright » Sun Oct 08, 2006 6:41 pm

The reason for adding the UniqueName is not so much for use at the moment but in the future. When I add a docking windows type control then it will need to be possible to uniquely name a page so that when performing persistence to and from configuration file it can uniquely find the right page to configure. I called it UniqueName so it was obvious what the intention of the value should be.

I think the solution for now is to change the string indexer so that if it cannot find a matching unique name then it looks for a matching Name and if that is not found either then also check the Text property. That way it would be useable if users want the Name/Text/UniqueName.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Postby figuerres » Mon Oct 09, 2006 1:52 pm

Is the uniqe name a globaly uniqe name or scoped to the control ?

in any event I think what I said would work...

.Name for the value untill you have a duplicate.
when you see that then append a value to make it uniqe
like "StaffABDC123"
as needed

so in the simple cases the two names are the same.
as the app gets more complex then the uniqe name starts to show up as different.

?
figuerres
 
Posts: 38
Joined: Sun Jul 30, 2006 10:25 am


Return to Krypton Navigator

Who is online

Users browsing this forum: No registered users and 0 guests

cron