0

I'm working in a windows application. using VB.NET 1.1

I have an empty form, and I want to generate my design in load session (not in form_load event! but in my form's constructor)

So I know I must generate my components in constructor, but I don't know how to generate button events. I mean I haven't any button in design mode, and these are generating in run-time mode. so how I set button events in this session?

And if you have a better solution for run-time design generation, give it to me. thanks ;)

matzone
  • 5,703
  • 3
  • 17
  • 20
R.S
  • 207
  • 3
  • 8
  • 17
  • Another suggestion. For each type of control that has common properties using a class that inherits the control and sets the properties you want might help make things more readable – tinstaafl Jun 30 '13 at 13:02
  • @HighCore >> a good **ANSWER** is: our company's application is on .net1.1 platform. and I haven't permission to change company's application structure.... **SO** you should answer the question instead of ask a new question! – R.S Jul 01 '13 at 10:13
  • @HighCore .net1.1 is for visual studio 2003 , not 50 years ago! and I love my job, and don't want leave that. I say again my suggestion: please answer my question, if you can. and if you can't answer, please be silent. – R.S Aug 17 '13 at 05:42

1 Answers1

0

A few things.

  1. You may add controls at practically any point. It can be in the constructor, the Load, in response to another event, or when a custom method is called.

  2. You can wire up events by using AddHandler myButton.Click, AddressOf Button_Click. You'll have to define the Button_Click event handlder and it will need to have the appropriate signature, which for a button click is (sender as object, e as EventArgs).

  3. When in doubt, temporarily add a real control to you form and go to the hidden designer code (MyForm.vDesigner.vb) and see what is generated as a sample. Copy that code and move it into the main populating code. Then delete the control.

Good luck!

tcarvin
  • 10,715
  • 3
  • 31
  • 52