Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. i get an error (non-invocable member-- can't be used like a method) any help?

i get an error (non-invocable member-- can't be used like a method) any help?

Scheduled Pinned Locked Moved C#
helpdatabasequestion
7 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 12899746
    wrote on last edited by
    #1

    foreach (DataGridViewRow row in this.dataGridView1.Rows)
    {
    if (row.Cells(this.invoiceNO.Index).Value == true)
    {
    a.Add(row.Cells(this.invoiceNO.Index).Value);
    }
    }

    A 1 Reply Last reply
    0
    • M Member 12899746

      foreach (DataGridViewRow row in this.dataGridView1.Rows)
      {
      if (row.Cells(this.invoiceNO.Index).Value == true)
      {
      a.Add(row.Cells(this.invoiceNO.Index).Value);
      }
      }

      A Offline
      A Offline
      Afzaal Ahmad Zeeshan
      wrote on last edited by
      #2

      In C#, you access array elements using [] not (),

      if (row.Cells[this.invoiceNO.Index].Value == true)

      This will access the elements, instead of invoking it as a function. Indexers (C# Programming Guide)[^] Methods (C# Programming Guide)[^]

      The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

      M 1 Reply Last reply
      0
      • A Afzaal Ahmad Zeeshan

        In C#, you access array elements using [] not (),

        if (row.Cells[this.invoiceNO.Index].Value == true)

        This will access the elements, instead of invoking it as a function. Indexers (C# Programming Guide)[^] Methods (C# Programming Guide)[^]

        The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

        M Offline
        M Offline
        Member 12899746
        wrote on last edited by
        #3

        many thanks...but i get another error (Operator '==' cannot be applied to operands of type 'object' and 'bool')

        A 1 Reply Last reply
        0
        • M Member 12899746

          many thanks...but i get another error (Operator '==' cannot be applied to operands of type 'object' and 'bool')

          A Offline
          A Offline
          Afzaal Ahmad Zeeshan
          wrote on last edited by
          #4

          Member 12899746 wrote:

          Operator '==' cannot be applied to operands of type 'object' and 'bool'

          That simply means you need to cast it to boolean value first and then apply == operator, try,

          if ((bool)row.Cells[this.invoiceNO.Index].Value == true)

          There are many other ways to solve this, read, c# - Error 7 Operator '==' cannot be applied to operands of type 'object' and 'bool' - Stack Overflow[^]

          The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

          OriginalGriffO M 2 Replies Last reply
          0
          • A Afzaal Ahmad Zeeshan

            Member 12899746 wrote:

            Operator '==' cannot be applied to operands of type 'object' and 'bool'

            That simply means you need to cast it to boolean value first and then apply == operator, try,

            if ((bool)row.Cells[this.invoiceNO.Index].Value == true)

            There are many other ways to solve this, read, c# - Error 7 Operator '==' cannot be applied to operands of type 'object' and 'bool' - Stack Overflow[^]

            The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Or better, omit the test altogether:

            if ((bool)row.Cells[this.invoiceNO.Index].Value)

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            A 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              Or better, omit the test altogether:

              if ((bool)row.Cells[this.invoiceNO.Index].Value)

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

              A Offline
              A Offline
              Afzaal Ahmad Zeeshan
              wrote on last edited by
              #6

              There are 2 more ways to do this, in SO thread. ;-)

              The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

              1 Reply Last reply
              0
              • A Afzaal Ahmad Zeeshan

                Member 12899746 wrote:

                Operator '==' cannot be applied to operands of type 'object' and 'bool'

                That simply means you need to cast it to boolean value first and then apply == operator, try,

                if ((bool)row.Cells[this.invoiceNO.Index].Value == true)

                There are many other ways to solve this, read, c# - Error 7 Operator '==' cannot be applied to operands of type 'object' and 'bool' - Stack Overflow[^]

                The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

                M Offline
                M Offline
                Member 12899746
                wrote on last edited by
                #7

                it's work......... manythanks

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups