Kali said:
Thank you, Andy. Will take a look at the article. Some of the issues I'm
having are the event handlers compared to asp.net... onitemdatabound, etc.
I am able to add a combobox to a datagridview and populate its listitems,
however, I'm not able to keep that combobox when binding the data from an
existing set of data.
The way binding works in windows forms is different now, I think.
What I used to do is apply a style to the table.
I can't recall why, but there was an advantage to doing this in code rather
than the column collection.
Here's some old code which has a combo box in it.
=======
Dim ts1 As New DataGridTableStyle()
ts1.MappingName = "Salesmen"
ts1.AlternatingBackColor = Color.LightBlue
Dim TextCol_0 As New DataGridTextBoxColumn()
TextCol_0.MappingName = "Salesman_Id"
TextCol_0.HeaderText = "Salesman Id"
TextCol_0.Width = 70
TextCol_0.TextBox.MaxLength = 8
ts1.GridColumnStyles.Add(TextCol_0)
'=========
Dim cboReg As New DataGridBoundComboColumn
cboReg.MappingName = "Region_Id"
cboReg.HeaderText = "Region"
cboReg.Width = 120
Try
Dim sconn As String = Conn_String()
Dim conn As SqlConnection = New SqlConnection(sconn)
Dim SqlString As String = "select null as region_id, '(Null)' as Region " &
_
"Union " & _
"Select Region_id, Region from Regions " & _
"order by Region"
Dim daRg = New SqlDataAdapter(SqlString, conn)
Dim dsRg = New DataSet
daRg.Fill(dsRg, "Regions")
With cboReg.ColumnBoundComboBox
..DataSource = dsRg.Tables("Regions").DefaultView
..DisplayMember = "Region"
..ValueMember = "Region_id"
End With
Catch ex As SqlException
MsgBox("Error reading Regions " & ex.Number & " " & ex.Message())
End Try
ts1.PreferredRowHeight = cboReg.ColumnBoundComboBox.Height + 3
ts1.GridColumnStyles.Add(cboReg)
'=====
Dim TextCol_3 As New DataGridTextBoxColumn
TextCol_3.MappingName = "Salesman_Name"
TextCol_3.HeaderText = "Salesman Name"
TextCol_3.Width = 110
TextCol_3.TextBox.MaxLength = 30
ts1.GridColumnStyles.Add(TextCol_3)
Dim TextCol_4 As New DataGridBoolColumn
TextCol_4.MappingName = "Manager"
TextCol_4.HeaderText = "Manager"
TextCol_4.Width = 50
TextCol_4.AllowNull = False
TextCol_4.FalseValue = "N"
TextCol_4.TrueValue = "Y"
ts1.GridColumnStyles.Add(TextCol_4)
Me.grdSalesmen.TableStyles.Add(ts1)