Error while setting an empty string to the cell text of type combo

Posted by: shuvendu-das on 8 September 2017, 1:41 pm EST

  • Posted 8 September 2017, 1:41 pm EST


    Hi Scott, 


    the below method is throwing an error if display text is empty.


    Pls let us know what chnages we need to make .Over come the error. 


    We are using the version : - 4.0.2009.2005


    public string GetListItemData( int row , int column , string displayText )


    {


    FpCombo fpCombo = this.GetListBoxAt( row , column );


    int index = fpCombo.List.IndexOf( displayText );


    if ( index != -1 )


    {


    this.Cells[ row , column ].Text = displayText;


    this.Cells[ row , column ].Invalidate( );


    return fpCombo.ItemData[ index ].ToString( );


    }


    return string.Empty;


    }


     


    Regards


    Shuvendu

  • Replied 8 September 2017, 1:41 pm EST

    Shuvendu,


    What line of code is throwing the error. It sounds like you may need to check the displayText string before your code and if it is empty then return String.Empty and not call the IndexOf method.

  • Replied 8 September 2017, 1:41 pm EST

    Hi scott,


    int index = fpCombo.List.IndexOf( displayText ); //i am getting the correct index


    if ( index != -1 )


    {


    this.Cells[ row , column ].Text = displayText; // This line gives me the error


    this.Cells[ row , column ].Invalidate( );


    return fpCombo.ItemData[ index ].ToString( );


    }


    And the above code working well in the previous version of the farpoint.Today i installed the new version 4.0.2009.2005 after that


    i got this error.


    Regards


    Shuvendu 


     

  • Replied 8 September 2017, 1:41 pm EST

    Shuvendu,


    I tested this code and it returned the ItemData for the string that was set to an empty string correctly. Could you post a small zipped project reproducing this issue for us to debug?

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels