I have a datagrid that is set up when I do a search against a database.
When I do the search, the columns are added correctly with the type of table I get the data from in mind. So I can represent different tables and different sets of columns in the same datagrid.
The thing is that I can only do this when accessing the form manually and doing the search my self. I want to use the same capabillities in other parts of the program by just calling a function. The function sets up the search like i want it to, controlled by the arguments I pass to it. The search gets done and gets stored in the datagrid of the form where all the code is written. This is the same form and the same datagrid I see when I do the search manually through that form.
I dont want the results of the search to stay in that datagrid at the original form. I want them returned from the function to whatever part of the program/ whatever form I call the function from. So I tried to return the datagrid from where the search results were stored.
I did not succeed. Any one have any ideas / comments?
Public Function get_Search(ByVal RegNumber As Integer, ByVal chkBoxes As Integer, ByVal indexNumber As Integer, ByVal SearchString As String)
Dim sender As System.Object = Me
Dim e As System.EventArgs
'... the code handles the arguments and sets up the search as if it were the user selecting in the search form....
' The search is the executed..
' In the btnFind_Click procedure, the results are stored in datagridSok. I want to return the
' datagrid or the columns and assign them to another already existing datagrid in another form:
'What I have come up with so far is this(done in another form):
Private Sub btnTestSok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestSok.Click
Dim tempDataGridViewColumnCollection As System.Windows.Forms.DataGridViewColumnCollection
tempDataGridViewColumnCollection = frmSok.get_Search(1, 1, 1, "String")
'The following does not work, I have tried numerous variants...