S
Shawn
I am trying to use a DataGridView to display one column of textboxes with a
single value from a query and then next to it have a combobox that displays
results from another query. What happens is the second query just returns 1
value to each combobox. So, in other words, for each textbox, the next
result of the second query puts 1 value in the corresponding combobox.
Here is my code... What the heck am I doing wrong????
cmd = frmMainForm.cnnShared.CreateCommand
cmd.CommandText = "select ID, DateEntered, Officer, FireExtID, State, Notes,
FireExtIDNum from FireExtClearingHouse"
cmd.CommandType = System.Data.CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "Checks")
CmdExt = frmMainForm.cnnShared.CreateCommand
CmdExt.CommandText = "select ID, Name from FireExtinguishers"
CmdExt.CommandType = System.Data.CommandType.Text
da.SelectCommand = CmdExt
da.Fill(dsExt, "Ext")
dgMain.DataSource = ds.Tables(0)
dgMain.Columns.Clear()
Dim dgColID As New DataGridViewTextBoxColumn
dgColID.DataPropertyName = "FireExtID"
dgColID.HeaderText = "Extinguisher ID"
dgColID.SortMode = DataGridViewColumnSortMode.NotSortable
dgMain.Columns.Add(dgColID)
Dim dgColSelect As New DataGridViewComboBoxColumn
With dgColSelect
..DataPropertyName = "ID"
..DataSource = dsExt.Tables("Ext")
..DisplayMember = "Name"
..ValueMember = "ID"
..HeaderText = "Extinguishers in the database"
..SortMode = DataGridViewColumnSortMode.NotSortable
End With
dgMain.Columns.Add(dgColSelect)
single value from a query and then next to it have a combobox that displays
results from another query. What happens is the second query just returns 1
value to each combobox. So, in other words, for each textbox, the next
result of the second query puts 1 value in the corresponding combobox.
Here is my code... What the heck am I doing wrong????
cmd = frmMainForm.cnnShared.CreateCommand
cmd.CommandText = "select ID, DateEntered, Officer, FireExtID, State, Notes,
FireExtIDNum from FireExtClearingHouse"
cmd.CommandType = System.Data.CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "Checks")
CmdExt = frmMainForm.cnnShared.CreateCommand
CmdExt.CommandText = "select ID, Name from FireExtinguishers"
CmdExt.CommandType = System.Data.CommandType.Text
da.SelectCommand = CmdExt
da.Fill(dsExt, "Ext")
dgMain.DataSource = ds.Tables(0)
dgMain.Columns.Clear()
Dim dgColID As New DataGridViewTextBoxColumn
dgColID.DataPropertyName = "FireExtID"
dgColID.HeaderText = "Extinguisher ID"
dgColID.SortMode = DataGridViewColumnSortMode.NotSortable
dgMain.Columns.Add(dgColID)
Dim dgColSelect As New DataGridViewComboBoxColumn
With dgColSelect
..DataPropertyName = "ID"
..DataSource = dsExt.Tables("Ext")
..DisplayMember = "Name"
..ValueMember = "ID"
..HeaderText = "Extinguishers in the database"
..SortMode = DataGridViewColumnSortMode.NotSortable
End With
dgMain.Columns.Add(dgColSelect)