Accessing Forms from a Class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form created in the IDE and I want to access a combo bix control on
this from. How do I do it?
 
Ithaqua said:
I have a form created in the IDE and I want to access a combo bix control
on
this from. How do I do it?

You may want to pass a reference pointing to the form's instance to the
class.
 
You may not want to do that. It is technically possible but possibly bad
programming practice to reference your UI elements from your classes.
Instead it is better to have the code in your classes UI independent.
Therefore, I would recommend referencing your class from your UI instead and
calling methods of your class passing information from the form. For example:

'*** In form load event create the class
MyClass = New MyClass


'*** In a button click or some other UI event handler call the method on
'*** the class passing the data from the form.
MyClass.DoSomething(txtTextBox.Text)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top