Passing ComboBox datasource in method

wallaceoc

New member
Joined
Oct 5, 2006
Messages
2
Programming Experience
1-3
Hi everyone,

It's been a long while since I did vb.net and I can't remember how to do something very simple!!!

I have a ComboBox on form1 and another one on Form2. What I want to do is when the user clicks on a button that loads form2 I want to pass the DataSource from the ComboBox on form1 to the one on form2.

I assume this is possible but have a few questions:
1) Do I pass the paramater ByVal or ByRef?
2) Do I have the paramater on form2 as a type Object?
3) Is something like this enough?

Form1
CODE

VB.NET:
Private Sub btnManage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnManage.Click
Me.frmManageReports = New frmReportManage
Me.frmManageReports.setupFromReport(Me.cmbReport.DataSource)
Me.frmManageReports.Visible = True
End Sub

Form2
CODE

VB.NET:
Public Sub setupFromReport(ByVal [URL="http://www.tek-tips.com/viewthread.cfm?qid=1287954&page=1#"]data[/URL] As Object)
Me.cmbFromReport.DataSource = data
Me.cmbFromReport.Enabled = True
End Sub

Thanks for the help in advance.

Wallace
 
Last edited by a moderator:
Back
Top