Hey guys i need some help on how to create a connection of a relationship between two forms...for example I have a DataGridView on another form....with a search button.. if i click the search button another window will pop out with a text box lable "Look For:" and a combobox "Look In:" that contains all the field names in that particular datagridview.
Yes..for Example I have a Datagridview on the Form1 with Search button then on the 2nd form has the textbox and combo box........so when i click the search button (form1) the form 2 will apear with the Textbox and a Combo box the combo box will be filled with all the field names in the form1 data table.
dim RecordID as integer
dim DT as datatable
Dim DS as new dataset
Dim DA as new OleDBDataAdapter
dim mCmd as new OleDbCommand
dim DetialsForm as new Form2
'I will assume your datagrid has row selection and the primary key of the record is in cell 0
dim Conn as new OleDbConnection(Connectionstring)
IF MyDatagridView.SelectedRows.Count>0 then
RecordID = MyDatagridView.SelectedRows(0).Cell(0).value
mCmd.Connection = Conn
mCmd.CommandType = CommandType.Text
mCmd.Text ="SELECT * FROM MyTable WHERE(MyID =" &RecordID &")"
DA.SelectCommand = mCmd
DT = DS.Tables(0)
'now for the putting stuff on to the other form...
'For speed I'll just stick evrything into a datagridview
DetailsForm.DataGridView1.Datasource = DT