How do I make a class for a button? I need multiple buttons based on items retrieved.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Audie7734
    New Member
    • Jul 2008
    • 8

    #1

    How do I make a class for a button? I need multiple buttons based on items retrieved.

    I am working on a program where I need to read files. I won't know how many buttons I need until run time. I can't figure out how to create a button class I can call at run time. Each button will represent a file. I want each button when clicked to open the correct file and place the data into a rich text box on the form.

    Also, I need buttons to appear tightly in a row or multiple rows.
  • David Gluth
    New Member
    • Oct 2010
    • 46

    #2
    1. Use a FlowLayoutPanel . Place this control on your form as you would a panel or groupbox. This is where you will put your buttons. It will allow the buttons to line up side by side or top to bottom as you set it parameters.
    2. In code for each file you will create a new instance of a button (dim myButton as new button), override its click event handler to point to the sub routine that will handle that input file.
    3. Add the button to the control - Me.flowLayoutPa nel.controls.ad d(mybutton)

    Comment

    • Audie7734
      New Member
      • Jul 2008
      • 8

      #3
      Thank you David. I was thinking I needed to create a seperate class. I forgot about (Dim myButton As New Button) You answered all my Questons, Thanks again.

      Comment

      Working...