Length cannot be less than zero exception

Hello,

I got an exception when I use delete button on keyboard.
Length cannot be less than zero. Parameter name: length at System.String.Substring

My sample;
<autocomplete:SfAutoComplete Grid.Row="0"
                                             WidthRequest="150"
                                             AutoCompleteMode="Suggest"
                                             MultiSelectMode="Token"
                                             DropDownItemHeight="30"
                                             TokensWrapMode="Wrap"
                                             HeightRequest="50"
                                             IsSelectedItemsVisibleInDropDown="False"
                                             FontFamily="Avenir-Light"
                                             DisplayMemberPath="Name"
                                             WatermarkColor="#35C6E5"
                                             IgnoreDiacritic="false"
                                             HighlightedTextColor="#35C6E5" 
                                             TextHighlightMode="FirstOccurrence"
                                             SuggestionMode="StartsWith"
                                             BorderColor="#35C6E5"
                                             DataSource="{Binding EmployeeList}">
</autocomplete:SfAutoComplete>

Regards,

5 Replies

RB Rabhia Beham Kathar Mideenar Syncfusion Team March 29, 2018 12:40 PM UTC

Hi yigit ozaksut,

We have checked your code snippet and have prepared a sample using SfAutoComplete Control. We could not reproduce the issue from our side. Please have the sample from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/136718/ze/AutoComplete21_4275378255 

If the issue still persists please modify the same with the issue reproducing steps, the device details and also provide in which platform you could reproduce the issue which will be helpful for us to analyse further and provide an appropriate solution.

Please let us know if you have any concern.

Regards,
Rabhia Beham K. 



YO yigit ozaksut April 3, 2018 12:14 PM UTC

Hello,
I try AutoComplete21_4275378255 sample on real device (iPhone 7) when I press remove button I got "Length cannot be less than zero." Exception

{System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
  at System.String.Substring (System.Int32 startIndex, System.Int32 length) [0x00087] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/string.cs:1266 
  at Syncfusion.SfAutoComplete.iOS.SfAutoComplete.Handle_ShouldChangeCharacters (UIKit.UITextField textField, Foundation.NSRange range, System.String replacementString) [0x000d0] in <8a80782699a64717804223c92777239c>:0 
  at UIKit.UITextField+_UITextFieldDelegate.ShouldChangeCharacters (UIKit.UITextField textField, Foundation.NSRange range, System.String replacementString) [0x0000d] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UITextField.cs:136 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at AutoComplete21.iOS.Application.Main (System.String[] args) [0x00002] in C:\Users\Yigit\Downloads\AutoComplete21_4275378255\AutoComplete21\iOS\Main.cs:15 }


RB Rabhia Beham Kathar Mideenar Syncfusion Team April 4, 2018 11:59 AM UTC

Hi yigit ozaksut,

We have checked the reported issue in SfAutoComplete Control. Unfortunately we could not reproduce the issue from our side . Please provide the video for the same with issue reproducing steps which will be helpful for us to analyse further and provide an appropriate solution.

Please let us know if you have any concern.

Regards,
Rabhia Beham K.



EE Espen Evje April 20, 2018 12:59 PM UTC

I have had the same problem.
I used to refer to the Text property and then the error happened.
When I changed to referring to the event parameter for the ValueChanged event all worked correctly.

autoLocations.ValueChanged += async (sendere) =>
{
     
var s = autoLocations.Text;  //When typed "O", the value of s is "". When typed "Os", the value of s is "O"
          var s = e.Value;  //When typed "O", the value of s is "O". When typed "Os", the value of s is "Os"
};

When using the delete button, the OutOfRangeException happened for the string that had a missing character.

Regards
Espen Evje


RB Rabhia Beham Kathar Mideenar Syncfusion Team April 23, 2018 06:48 AM UTC

Hi Espen,

Thanks for contacting Syncfusion Support.

Query : When typed "O", the value of s is "". When typed "Os", the value of s is "O" in autoComplete.Text.

We could able to reproduce the issue in SfAutoComplete Control in Xamarin Forms iOS. We are currently working on the issue and fix for the same will be available in Volume 2 Release which is expected to be rolled out by the end of May 2018.

Please let us know if you have any concern.

Regards,
Rabhia Beham K.

Loader.
Up arrow icon