By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,576 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,576 IT Pros & Developers. It's quick & easy.

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

P: 8
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.
Dec 28 '10 #1

✓ answered by David Gluth

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.flowLayoutPanel.controls.add(mybutton)

Share this Question
Share on Google+
2 Replies


P: 46
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.flowLayoutPanel.controls.add(mybutton)
Dec 29 '10 #2

P: 8
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.
Dec 30 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.