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. Visual Basic
  4. This control array should work, right?

This control array should work, right?

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasedata-structuresquestion
6 Posts 3 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.
  • D Offline
    D Offline
    David Williams
    wrote on last edited by
    #1

    I know .NET is different than 6 wrt control arrays. But shouldn't I be able to capture the CLICK on the following (fragment)? Dim contArray(2) as Button for i = 0 to 1 contArray(i) = new Button contArray(i).tag = i controls.add(contArray(i)) next i ... private sub contArray_CLICK (...) or something that lets me get the tag or index of the button clicked. -David

    R 1 Reply Last reply
    0
    • D David Williams

      I know .NET is different than 6 wrt control arrays. But shouldn't I be able to capture the CLICK on the following (fragment)? Dim contArray(2) as Button for i = 0 to 1 contArray(i) = new Button contArray(i).tag = i controls.add(contArray(i)) next i ... private sub contArray_CLICK (...) or something that lets me get the tag or index of the button clicked. -David

      R Offline
      R Offline
      Ray Cassick
      wrote on last edited by
      #2

      Here is an example of how to do it in both VB.NET and C# CodeProject Clickety[^] Please keep in mind that I do not like how the article is formatted, but the content is ok.


      Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
      George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


      D 2 Replies Last reply
      0
      • R Ray Cassick

        Here is an example of how to do it in both VB.NET and C# CodeProject Clickety[^] Please keep in mind that I do not like how the article is formatted, but the content is ok.


        Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
        George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


        D Offline
        D Offline
        David Williams
        wrote on last edited by
        #3

        Thanks, works pretty good. If I want to add the control array to a panel instead of a form, how would I declare the control?

        1 Reply Last reply
        0
        • R Ray Cassick

          Here is an example of how to do it in both VB.NET and C# CodeProject Clickety[^] Please keep in mind that I do not like how the article is formatted, but the content is ok.


          Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
          George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


          D Offline
          D Offline
          David Williams
          wrote on last edited by
          #4

          Thanks, works pretty good. If I want to add the control array to a panel instead of a form, how would I declare the control? assuming a Panel1 on the main form, Dim ControlArray as ButtonArray(Panel1) 'doesn't work since Panel1 is not a "form" container

          M 1 Reply Last reply
          0
          • D David Williams

            Thanks, works pretty good. If I want to add the control array to a panel instead of a form, how would I declare the control? assuming a Panel1 on the main form, Dim ControlArray as ButtonArray(Panel1) 'doesn't work since Panel1 is not a "form" container

            M Offline
            M Offline
            mikasa
            wrote on last edited by
            #5

            Instead, change the Form reference to be an "IContainer" control since all Controls and Forms inherit from IContainer.

            D 1 Reply Last reply
            0
            • M mikasa

              Instead, change the Form reference to be an "IContainer" control since all Controls and Forms inherit from IContainer.

              D Offline
              D Offline
              David Williams
              wrote on last edited by
              #6

              Thanks for the reply. But I'm new to .NET. If you mean, have the main form inherit from System.Windows.Form.IContainerControl it doesn't work. At least I get an error that says classes can inherit only from classes.

              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