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. Managed C++/CLI
  4. buttons exception

buttons exception

Scheduled Pinned Locked Moved Managed C++/CLI
comhostingdata-structures
4 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    staticv
    wrote on last edited by
    #1

    Why is this code throwing exception

    gameBoard->gameBtns = gcnew array<Button^>(GameBoard::TOTAL_BOXES);

    for each(Button^ btn in gameBoard->gameBtns)
    btn->Enabled = true;

    where TOTAL_BOXES is defined as 9 but this code doesn't

    Button^ temp = gcnew Button();
    temp->Enabled = true;

    Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

    L 1 Reply Last reply
    0
    • S staticv

      Why is this code throwing exception

      gameBoard->gameBtns = gcnew array<Button^>(GameBoard::TOTAL_BOXES);

      for each(Button^ btn in gameBoard->gameBtns)
      btn->Enabled = true;

      where TOTAL_BOXES is defined as 9 but this code doesn't

      Button^ temp = gcnew Button();
      temp->Enabled = true;

      Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi,

      Ahmed Manzoor wrote:

      Button^ temp = gcnew Button();

      creates a button, so you can operate on it.

      Ahmed Manzoor wrote:

      gameBtns = gcnew array<button^>(GameBoard::TOTAL_BOXES);

      Does not generate any buttons, all it does is generate an array that will be able to hold some buttons. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


      S 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi,

        Ahmed Manzoor wrote:

        Button^ temp = gcnew Button();

        creates a button, so you can operate on it.

        Ahmed Manzoor wrote:

        gameBtns = gcnew array<button^>(GameBoard::TOTAL_BOXES);

        Does not generate any buttons, all it does is generate an array that will be able to hold some buttons. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


        S Offline
        S Offline
        staticv
        wrote on last edited by
        #3

        so I'll have to generate each button individually?

        Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

        L 1 Reply Last reply
        0
        • S staticv

          so I'll have to generate each button individually?

          Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Ahmed Manzoor wrote:

          so I'll have to generate each button individually?

          Yes. You did it when you needed one, what makes you think you don't have to when you want a lot of them? BTW: array elements are initialized to null; you only need to create as many buttons as you need, you can leave the non-essential elements, if any, at null. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


          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