locked
Overload resolution failed because no accessible 'Item' can be called without a narrowing conversion

    Question

  • I need to pass all the datagridview data to one string. Below is my code. The underline coding is pops up the error.

     

    Error:

    Error    1   
    Overload resolution failed because no accessible 'Item' can be called without a narrowing conversion:
        'Public Default Property Item(columnName As String) As System.Windows.Forms.DataGridViewCell': Argument matching parameter 'columnName' narrows from 'Long' to 'String'.
        'Public Default Property Item(index As Integer) As System.Windows.Forms.DataGridViewCell': Argument matching parameter 'index' narrows from 'Long' to 'Integer'.

     

    Code:

                        For idx = 0 To dgvRpt.RowCount - 1
                            For idy = 0 To dgvRpt.ColumnCount - 1
                                sRptData = dgvRpt.Rows(idx).Cells(idy).value
                            Next
                        Next

     

    Friday, July 08, 2011 12:39 PM

Answers

  • Without a question you ask ( please do this the next time):

    1. sRptData = dgvRpt.Rows(idx).Cells(idy).value.toString()

    2. declare idx and idy to be Integer instead of Long


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by Giin Sing Friday, July 08, 2011 1:01 PM
    Friday, July 08, 2011 12:48 PM

All replies

  • Without a question you ask ( please do this the next time):

    1. sRptData = dgvRpt.Rows(idx).Cells(idy).value.toString()

    2. declare idx and idy to be Integer instead of Long


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by Giin Sing Friday, July 08, 2011 1:01 PM
    Friday, July 08, 2011 12:48 PM
  • Thanks, Heslacher
    Friday, July 08, 2011 1:01 PM