2

I have a search-bar in my application, And i'm not to sure what the best practice is?

Is it First Upper, Rest Lower. All Lower, All Upper

And what is the best way to Approach First upper, Rest Lower?

Filtering my Listview in relation to the Search Text, In my Context I have Suppliers Submitting there own Name's and alot of the time's I end up with, E.G SUPPLIER1 Supplier2 supplier3 SUPplier4 Type of situations

 if (string.IsNullOrWhiteSpace(e.NewTextValue))
     productsListView.FlowItemsSource = Tags;
 else
     productsListView.FlowItemsSource = Tags
        .Where(i => i
           .name
           .ToLower()
           .Contains(e.NewTextValue))
        .ToList();

If I say something like

First().ToString().ToUpper().ToLower()

I'm just dropping The first to a lower again.

I'm curious as with IOS devices you usually have the first letter Uppercase, And for less technical clients it's better to Cater for that is it not?

Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
Someguy
  • 414
  • 3
  • 16
  • 1
    What are you trying to do here? `i.name.ToLower().First().ToString().ToUpper()` gives you one single uppercase letter. How is this related to a search bar? – Sweeper Feb 04 '20 at 07:20
  • My Apologies i Updated, Its Filtering a List view to only display whatever is in relation to the search bar, And I realised that the devices usually start with a capital and it would be annoying to have someone deselect that and then only start typing – Someguy Feb 04 '20 at 07:24
  • Searches are usually case insensitive, Why bother with case? – TheGeneral Feb 04 '20 at 07:25
  • 1
    It sounds like you're using Xamarin iOS? I'm pretty sure you can change the auto capitalisation of the text field to not capitalise anything. – Sweeper Feb 04 '20 at 07:25
  • I can Switch everything from lower/Upper very easily I just have suppliers submitting there own name's And they tend to be very wacky with the naming, As in All caps all lowercase Random Uppercase's, This is done on a Web Forum I have no control over sadly, @Sweeper ah actually your right I probably could just remove the Auto capitalisation and then push everything to lower – Someguy Feb 04 '20 at 07:28

1 Answers1

2

For search-bar use all data to lower. I mean your search keyword and all content must be to lower.

i.Where(c => c.Content.ToLower() == searchstring.ToLower())

This will give you all results.

For writing first upper and all next lower you can use

i.name.ToLower().First().ToString().ToUpper()
  • It's basically what I tried, But yeah I mean your Technically right so, But I did end up just removing the Auto Capitalisation and just said .ToLower() for everything – Someguy Feb 05 '20 at 06:25